Skip to contentSkip to conversation

md/dm-mpath: Add NULL pointer check in parse_hw_handler()

PATCH New [email protected] 1 participant 1 message Oct 28, 2016 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 md/dm-mpath: Add NULL pointer check in parse_hw_handler()

From: "tang.junhui" <[email protected]>

m->hw_handler_name value should be checked in parse_hw_handler() after calling kstrdup() to avoid access of NULL pointer.

---
 drivers/md/dm-mpath.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/md/dm-mpath.c +3 -0
index d376dc8..77428fb 100644
@@ -732,6 +732,9 @@ static int parse_hw_handler(struct dm_arg_set *as, struct multipath *m)
 		return 0;
 
 	m->hw_handler_name = kstrdup(dm_shift_arg(as), GFP_KERNEL);
+	if (!m->hw_handler_name)
+		return -ENOMEM;
+
 	if (!try_then_request_module(scsi_dh_handler_exist(m->hw_handler_name),
 				     "scsi_dh_%s", m->hw_handler_name)) {
 		ti->error = "unknown hardware handler type";
Signature · 1 line
2.8.1.windows.1