9p: potential NULL dereference
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 26 Sep 2018 10:39:34 +0000 (13:39 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Jul 2019 11:14:42 +0000 (13:14 +0200)
[ Upstream commit 72ea0321088df2c41eca8cc6160c24bcceb56ac7 ]

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.

Link: http://lkml.kernel.org/m/20180926103934.GA14535@mwanda
Fixes: 996d5b4db4b1 ("9p: Use a slab for allocating requests")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/9p/client.c

index 4becde9..b615aae 100644 (file)
@@ -287,7 +287,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;