Skip to content

Commit bbeb18f

Browse files
anirudhrbgregkh
authored andcommitted
net/smc: properly handle workqueue allocation failure
In smcd_alloc_dev(), if alloc_ordered_workqueue() fails, properly catch it, clean up and return NULL to let the caller know there was a failure. Move the call to alloc_ordered_workqueue higher in the function in order to abort earlier without needing to unwind the call to device_initialize(). Cc: Ursula Braun <ubraun@linux.ibm.com> Cc: David S. Miller <davem@davemloft.net> Signed-off-by: Anirudh Rayabharam <mail@anirudhrb.com> Link: https://lore.kernel.org/r/20210503115736.2104747-18-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5369ead commit bbeb18f

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎net/smc/smc_ism.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,14 @@ struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name,
402402
return NULL;
403403
}
404404

405+
smcd->event_wq = alloc_ordered_workqueue("ism_evt_wq-%s)",
406+
WQ_MEM_RECLAIM, name);
407+
if (!smcd->event_wq) {
408+
kfree(smcd->conn);
409+
kfree(smcd);
410+
return NULL;
411+
}
412+
405413
smcd->dev.parent = parent;
406414
smcd->dev.release = smcd_release;
407415
device_initialize(&smcd->dev);
@@ -415,8 +423,6 @@ struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name,
415423
INIT_LIST_HEAD(&smcd->vlan);
416424
INIT_LIST_HEAD(&smcd->lgr_list);
417425
init_waitqueue_head(&smcd->lgrs_deleted);
418-
smcd->event_wq = alloc_ordered_workqueue("ism_evt_wq-%s)",
419-
WQ_MEM_RECLAIM, name);
420426
return smcd;
421427
}
422428
EXPORT_SYMBOL_GPL(smcd_alloc_dev);

0 commit comments

Comments
 (0)