Skip to contentSkip to conversation

staging: lustre: obd: check for allocation failure

PATCH In review Dan Carpenter 2 participants 2 messages Aug 23, 2017

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

PATCH 1/1 staging: lustre: obd: check for allocation failure

lustre_cfg_new() can fail with ERR_PTR(-ENOMEM) so we should check for that.

Fixes d7e09d0397e8 ("staging: add Lustre file system client support")
drivers/staging/lustre/lustre/obdclass/obd_mount.c +2 -0
index 8e0d4b1d86dc..7cb99f11caa0 100644
@@ -159,6 +159,8 @@ static int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd,
 		lustre_cfg_bufs_set_string(&bufs, 4, s4);
 
 	lcfg = lustre_cfg_new(cmd, &bufs);
+	if (IS_ERR(lcfg))
+		return PTR_ERR(lcfg);
 	lcfg->lcfg_nid = nid;
 	rc = class_process_config(lcfg);
 	lustre_cfg_free(lcfg);
#1 lore raw
Quoted 11 lines · Dan Carpenter

lustre_cfg_new() can fail with ERR_PTR(-ENOMEM) so we should check for that.

Fixes d7e09d0397e8 ("staging: add Lustre file system client support")
drivers/staging/lustre/lustre/obdclass/obd_mount.c +0 -0
index 8e0d4b1d86dc..7cb99f11caa0 100644

drivers/staging/lustre/lustre/obdclass/obd_mount.c static int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd, · line 166

Quoted 8 lines
drivers/staging/lustre/lustre/obdclass/obd_mount.c +2 -0
@@ -159,6 +159,8 @@ static int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd,
 		lustre_cfg_bufs_set_string(&bufs, 4, s4);
 
 	lcfg = lustre_cfg_new(cmd, &bufs);
+	if (IS_ERR(lcfg))
+		return PTR_ERR(lcfg);
 	lcfg->lcfg_nid = nid;
 	rc = class_process_config(lcfg);
 	lustre_cfg_free(lcfg);

Doesn't apply to my tree anymore :(