[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211209025038.2028112-1-jiasheng@iscas.ac.cn>
Date:   Thu,  9 Dec 2021 10:50:38 +0800
From:   Jiasheng Jiang <jiasheng@...as.ac.cn>
To:     idryomov@...il.com, jlayton@...nel.org, davem@...emloft.net,
        kuba@...nel.org
Cc:     ceph-devel@...r.kernel.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org, Jiasheng Jiang <jiasheng@...as.ac.cn>
Subject: [PATCH] libceph, ceph: potential dereference of null pointer
The return value of kzalloc() needs to be checked.
To avoid use of null pointer in case of the failure of alloc.
Fixes: 3d14c5d2b6e1 ("ceph: factor out libceph from Ceph file system")
Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
---
 net/ceph/osd_client.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index ff8624a7c964..3203e8a34370 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -1234,6 +1234,8 @@ static struct ceph_osd *create_osd(struct ceph_osd_client *osdc, int onum)
 	WARN_ON(onum == CEPH_HOMELESS_OSD);
 
 	osd = kzalloc(sizeof(*osd), GFP_NOIO | __GFP_NOFAIL);
+	if (!osd)
+		return NULL;
 	osd_init(osd);
 	osd->o_osdc = osdc;
 	osd->o_osd = onum;
-- 
2.25.1
Powered by blists - more mailing lists
 
