diff
+#define CHECK_NULL(ptr) if (!(ptr)) return -EINVAL;
+
 static int remove_device_files(struct super_block *sb,
 			       struct qib_devdata *dd)
 {
 	struct dentry *dir;
 	char unit[10];
 
+	CHECK_NULL(sb);
+	CHECK_NULL(sb->s_root);
+
 	snprintf(unit, sizeof(unit), "%u", dd->unit);
 	dir = lookup_one_len_unlocked(unit, sb->s_root, strlen(unit));
