Skip to contentSkip to conversation

9p: potential NULL dereference

PATCH In review Dan Carpenter 2 participants 2 messages Sep 26, 2018

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

PATCH 1/1 9p: potential NULL dereference

p9_tag_alloc() is supposed to return error pointers, but we accidentally return a NULL here. It would cause a NULL dereference in the caller.

Fixes 996d5b4db4b1 ("9p: Use a slab for allocating requests")
net/9p/client.c +1 -1
index 47fa6158a75a..5f23e18eecc0 100644
@@ -281,7 +281,7 @@ p9_tag_alloc(struct p9_client *c, int8_t type, unsigned int max_size)
 	int tag;
 
 	if (!req)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	if (p9_fcall_init(c, &req->tc, alloc_msize))
 		goto free_req;
#1 lore raw

Dan Carpenter wrote on Wed, Sep 26, 2018:

Quoted 5 lines

p9_tag_alloc() is supposed to return error pointers, but we accidentally return a NULL here. It would cause a NULL dereference in the caller.

Fixes 996d5b4db4b1 ("9p: Use a slab for allocating requests")

Good catch, the culprit commit is only in -next so just adding this to the queue right away.

Thanks!

Signature · 1 line
Dominique