net: ieee802154: fix a potential NULL pointer dereference
authorKangjie Lu <kjlu@umn.edu>
Mon, 11 Mar 2019 07:25:17 +0000 (02:25 -0500)
committerStefan Schmidt <stefan@datenfreihafen.org>
Wed, 13 Mar 2019 09:07:53 +0000 (10:07 +0100)
In case alloc_ordered_workqueue fails, the fix releases
sources and returns -ENOMEM to avoid NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
drivers/net/ieee802154/adf7242.c

index cd1d8fa..cd6b95e 100644 (file)
@@ -1268,6 +1268,10 @@ static int adf7242_probe(struct spi_device *spi)
        INIT_DELAYED_WORK(&lp->work, adf7242_rx_cal_work);
        lp->wqueue = alloc_ordered_workqueue(dev_name(&spi->dev),
                                             WQ_MEM_RECLAIM);
+       if (unlikely(!lp->wqueue)) {
+               ret = -ENOMEM;
+               goto err_hw_init;
+       }
 
        ret = adf7242_hw_init(lp);
        if (ret)