main: Fix NULL deref error

Fix null dereference error.
Add a check for dev that avoids an oops before it happens.

Signed-off-by: Salym Senyonga <salymsash@gmail.com>