Skip to contentSkip to conversation

ceph: handle kmalloc() failure

PATCH Applied Dan Carpenter 2 participants 2 messages Mar 20, 2010 – Mar 21, 2010 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: handle kmalloc() failure

Return ERR_PTR(-ENOMEM) if kmalloc() fails. We handle allocation failures the same way later in the function.

fs/ceph/mds_client.c +2 -0
index a260010..655b005 100644
@@ -328,6 +328,8 @@ static struct ceph_mds_session *register_session(struct ceph_mds_client *mdsc,
 	struct ceph_mds_session *s;
 
 	s = kzalloc(sizeof(*s), GFP_NOFS);
+	if (!s)
+		return ERR_PTR(-ENOMEM);
 	s->s_mdsc = mdsc;
 	s->s_mds = mds;
 	s->s_state = CEPH_MDS_SESSION_NEW;
Applied
#1 lore raw
Quoted 10 lines · Dan Carpenter

Return ERR_PTR(-ENOMEM) if kmalloc() fails. We handle allocation failures the same way later in the function.

fs/ceph/mds_client.c +0 -0
index a260010..655b005 100644

fs/ceph/mds_client.c static struct ceph_mds_session *register_session(struct ceph_mds_client *mdsc, · line 335

Quoted 8 lines
fs/ceph/mds_client.c +2 -0
@@ -328,6 +328,8 @@ static struct ceph_mds_session *register_session(struct ceph_mds_client *mdsc,
 	struct ceph_mds_session *s;
 
 	s = kzalloc(sizeof(*s), GFP_NOFS);
+	if (!s)
+		return ERR_PTR(-ENOMEM);
 	s->s_mdsc = mdsc;
 	s->s_mds = mds;
 	s->s_state = CEPH_MDS_SESSION_NEW;

Applied, thanks!
sage