Skip to contentSkip to conversation

KEYS: remove a bogus NULL check

PATCH Applied Dan Carpenter 2 participants 2 messages Nov 22, 2014 – Nov 24, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KEYS: remove a bogus NULL check

We already checked if "desc" was NULL at the beginning of the function and we've dereferenced it so this causes a static checker warning.

security/keys/key.c +4 -6
index e17ba6a..aee2ec5 100644
@@ -276,12 +276,10 @@ struct key *key_alloc(struct key_type *type, const char *desc,
 	if (!key)
 		goto no_memory_2;
 
-	if (desc) {
-		key->index_key.desc_len = desclen;
-		key->index_key.description = kmemdup(desc, desclen + 1, GFP_KERNEL);
-		if (!key->description)
-			goto no_memory_3;
-	}
+	key->index_key.desc_len = desclen;
+	key->index_key.description = kmemdup(desc, desclen + 1, GFP_KERNEL);
+	if (!key->description)
+		goto no_memory_3;
 
 	atomic_set(&key->usage, 1);
 	init_rwsem(&key->sem);
maintainer Applied
#1 lore raw
Quoted 2 lines · Dan Carpenter

We already checked if "desc" was NULL at the beginning of the function and we've dereferenced it so this causes a static checker warning.

Yeah - keys were originally allowed to have no description.

Applied.