devicemgr: null-checking to prevent null pointer dereference