RE: [PATCH] net: ieee802154: fix a potential NULL pointer dereference

From: Hennerich, Michael
Date: Mon Mar 11 2019 - 03:30:36 EST




> -----Original Message-----
> From: Kangjie Lu [mailto:kjlu@xxxxxxx]
> Sent: Montag, 11. März 2019 08:25
> To: kjlu@xxxxxxx
> Cc: pakki001@xxxxxxx; Hennerich, Michael <Michael.Hennerich@xxxxxxxxxx>; Alexander Aring <alex.aring@xxxxxxxxx>; Stefan
> Schmidt <stefan@xxxxxxxxxxxxxxxxxx>; David S. Miller <davem@xxxxxxxxxxxxx>; linux-wpan@xxxxxxxxxxxxxxx;
> netdev@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
> Subject: [PATCH] net: ieee802154: fix a potential NULL pointer dereference
>
> In case alloc_ordered_workqueue fails, the fix releases
> sources and returns -ENOMEM to avoid NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@xxxxxxx>

Acked-by: Michael Hennerich <michael.hennerich@xxxxxxxxxx>

> ---
> drivers/net/ieee802154/adf7242.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/ieee802154/adf7242.c b/drivers/net/ieee802154/adf7242.c
> index cd1d8faccca5..cd6b95e673a5 100644
> --- a/drivers/net/ieee802154/adf7242.c
> +++ b/drivers/net/ieee802154/adf7242.c
> @@ -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)
> --
> 2.17.1