From: Kangjie Lu Date: Thu, 11 Apr 2019 09:17:31 +0000 (+0200) Subject: net/smc: fix a NULL pointer dereference X-Git-Tag: v5.1-rc6~21^2~24^2~3 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=e183d4e414b64711baf7a04e214b61969ca08dfa;p=uclinux-h8%2Flinux.git net/smc: fix a NULL pointer dereference In case alloc_ordered_workqueue fails, the fix returns NULL to avoid NULL pointer dereference. Signed-off-by: Kangjie Lu Signed-off-by: Ursula Braun Signed-off-by: David S. Miller --- diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c index 2fff79db1a59..e89e918b88e0 100644 --- a/net/smc/smc_ism.c +++ b/net/smc/smc_ism.c @@ -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);