2019-03-11 07:26:11

by Kangjie Lu

[permalink] [raw]
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 <[email protected]>
---
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



2019-03-11 07:31:18

by Hennerich, Michael

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



> -----Original Message-----
> From: Kangjie Lu [mailto:[email protected]]
> Sent: Montag, 11. M?rz 2019 08:25
> To: [email protected]
> Cc: [email protected]; Hennerich, Michael <[email protected]>; Alexander Aring <[email protected]>; Stefan
> Schmidt <[email protected]>; David S. Miller <[email protected]>; [email protected];
> [email protected]; [email protected]
> 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 <[email protected]>

Acked-by: Michael Hennerich <[email protected]>

> ---
> 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


2019-03-13 09:09:41

by Stefan Schmidt

[permalink] [raw]
Subject: Re: [PATCH] net: ieee802154: fix a potential NULL pointer dereference

Hello.

On 11.03.19 08:30, Hennerich, Michael wrote:
>
>
>> -----Original Message-----
>> From: Kangjie Lu [mailto:[email protected]]
>> Sent: Montag, 11. März 2019 08:25
>> To: [email protected]
>> Cc: [email protected]; Hennerich, Michael <[email protected]>; Alexander Aring <[email protected]>; Stefan
>> Schmidt <[email protected]>; David S. Miller <[email protected]>; [email protected];
>> [email protected]; [email protected]
>> 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 <[email protected]>
>
> Acked-by: Michael Hennerich <[email protected]>

Strange enough patchwork did not pick up this acked by from you. I added
in manually to the patch. Just so you know.

regards
Stefan Schmidt

2019-03-13 09:11:07

by Stefan Schmidt

[permalink] [raw]
Subject: Re: [PATCH] net: ieee802154: fix a potential NULL pointer dereference

Hello.

[please ignore the first mail, hit send to early]

On 11.03.19 08:25, Kangjie Lu wrote:
> In case alloc_ordered_workqueue fails, the fix releases
> sources and returns -ENOMEM to avoid NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <[email protected]>
> ---
> 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)
>


This patch has been applied to the wpan tree and will be
part of the next pull request to net. Thanks!

regards
Stefan Schmidt

2019-03-13 09:11:29

by Stefan Schmidt

[permalink] [raw]
Subject: Re: [PATCH] net: ieee802154: fix a potential NULL pointer dereference

Hello.

On 11.03.19 08:25, Kangjie Lu wrote:
> In case alloc_ordered_workqueue fails, the fix releases
> sources and returns -ENOMEM to avoid NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <[email protected]>
> ---
> 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)
>