Skip to content

Commit 23015b2

Browse files
kengitertorvalds
authored andcommitted
rapidio: fix a NULL pointer dereference when create_workqueue() fails
In case create_workqueue fails, the fix releases resources and returns -ENOMEM to avoid NULL pointer dereference. Signed-off-by: Kangjie Lu <kjlu@umn.edu> Acked-by: Alexandre Bounine <alex.bou9@gmail.com> Cc: Matt Porter <mporter@kernel.crashing.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 3713a4e commit 23015b2

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎drivers/rapidio/rio_cm.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,6 +2147,14 @@ static int riocm_add_mport(struct device *dev,
21472147
mutex_init(&cm->rx_lock);
21482148
riocm_rx_fill(cm, RIOCM_RX_RING_SIZE);
21492149
cm->rx_wq = create_workqueue(DRV_NAME "/rxq");
2150+
if (!cm->rx_wq) {
2151+
riocm_error("failed to allocate IBMBOX_%d on %s",
2152+
cmbox, mport->name);
2153+
rio_release_outb_mbox(mport, cmbox);
2154+
kfree(cm);
2155+
return -ENOMEM;
2156+
}
2157+
21502158
INIT_WORK(&cm->rx_work, rio_ibmsg_handler);
21512159

21522160
cm->tx_slot = 0;

0 commit comments

Comments
 (0)