Skip to contentSkip to conversation

net: smc: fix a NULL pointer dereference

PATCH In review Kangjie Lu 2 participants 2 messages Mar 15, 2019

Subsystems (4)
lore
Share & tools
lore

Kangjie Lu

author
#0 lore raw

PATCH 1/1 net: smc: fix a NULL pointer dereference

In case alloc_ordered_workqueue fails, the fix returns NULL to avoid NULL pointer dereference.

---
 net/smc/smc_ism.c | 5 +++++
 1 file changed, 5 insertions(+)
net/smc/smc_ism.c +5 -0
index 2fff79db1a59..e89e918b88e0 100644
@@ -289,6 +289,11 @@ struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name,
 	INIT_LIST_HEAD(&smcd->vlan);
 	smcd->event_wq = alloc_ordered_workqueue("ism_evt_wq-%s)",
 						 WQ_MEM_RECLAIM, name);
+	if (!smcd->event_wq) {
+		kfree(smcd->conn);
+		kfree(smcd);
+		return NULL;
+	}
 	return smcd;
 }
 EXPORT_SYMBOL_GPL(smcd_alloc_dev);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 3 lines · Kangjie Lu

In case alloc_ordered_workqueue fails, the fix returns NULL to avoid NULL pointer dereference.

Thanks, looks good. Your patch will be part of our next patch submission for the net-tree.

Regards, Ursula

Quoted 22 lines
---
 net/smc/smc_ism.c | 5 +++++
 1 file changed, 5 insertions(+)
net/smc/smc_ism.c +5 -0
index 2fff79db1a59..e89e918b88e0 100644
@@ -289,6 +289,11 @@ struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name,
 	INIT_LIST_HEAD(&smcd->vlan);
 	smcd->event_wq = alloc_ordered_workqueue("ism_evt_wq-%s)",
 						 WQ_MEM_RECLAIM, name);
+	if (!smcd->event_wq) {
+		kfree(smcd->conn);
+		kfree(smcd);
+		return NULL;
+	}
 	return smcd;
 }
 EXPORT_SYMBOL_GPL(smcd_alloc_dev);