Skip to content

Commit dc3f89c

Browse files
SinkFinderKalle Valo
authored andcommitted
libertas: check return value of alloc_workqueue
Function alloc_workqueue() will return a NULL pointer if there is no enough memory, and its return value should be validated before using. However, in function if_spi_probe(), its return value is not checked. This may result in a NULL dereference bug. This patch fixes the bug. Signed-off-by: Pan Bian <bianpan2016@163.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
1 parent 5fb01e9 commit dc3f89c

File tree

1 file changed

+5
-0
lines changed
  • drivers/net/wireless/marvell/libertas

1 file changed

+5
-0
lines changed

drivers/net/wireless/marvell/libertas/if_spi.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,10 @@ static int if_spi_probe(struct spi_device *spi)
11811181

11821182
/* Initialize interrupt handling stuff. */
11831183
card->workqueue = alloc_workqueue("libertas_spi", WQ_MEM_RECLAIM, 0);
1184+
if (!card->workqueue) {
1185+
err = -ENOMEM;
1186+
goto remove_card;
1187+
}
11841188
INIT_WORK(&card->packet_work, if_spi_host_to_card_worker);
11851189
INIT_WORK(&card->resume_work, if_spi_resume_worker);
11861190

@@ -1209,6 +1213,7 @@ static int if_spi_probe(struct spi_device *spi)
12091213
free_irq(spi->irq, card);
12101214
terminate_workqueue:
12111215
destroy_workqueue(card->workqueue);
1216+
remove_card:
12121217
lbs_remove_card(priv); /* will call free_netdev */
12131218
free_card:
12141219
free_if_spi_card(card);

0 commit comments

Comments
 (0)