* [-next] dmaengine: sprd: Fix potential NULL dereference in sprd_dma_probe()
@ 2018-05-07 1:40 ` Wei Yongjun
0 siblings, 0 replies; 14+ messages in thread
From: weiyongjun (A) @ 2018-05-07 1:40 UTC (permalink / raw)
To: Dan Williams, Vinod Koul, Orson Zhai, Baolin Wang, Chunyan Zhang
Cc: Wei Yongjun, dmaengine, kernel-janitors
platform_get_resource() may fail and return NULL, so we should
better check it's return value to avoid a NULL pointer dereference
a bit later in the code.
This is detected by Coccinelle semantic patch.
@@
expression pdev, res, n, t, e, e1, e2;
@@
res = platform_get_resource(pdev, t, n);
+ if (!res)
+ return -EINVAL;
... when != res == NULL
e = devm_ioremap_nocache(e1, res->start, e2);
Fixes: 9b3b8171f7f4 ("dmaengine: sprd: Add Spreadtrum DMA driver")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
drivers/dma/sprd-dma.c | 2 ++
1 file changed, 2 insertions(+)
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
index ccdeb8f..dba7a17 100644
--- a/drivers/dma/sprd-dma.c
+++ b/drivers/dma/sprd-dma.c
@@ -807,6 +807,8 @@ static int sprd_dma_probe(struct platform_device *pdev)
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res)
+ return -EINVAL;
sdev->glb_base = devm_ioremap_nocache(&pdev->dev, res->start,
resource_size(res));
if (!sdev->glb_base)
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH -next] dmaengine: sprd: Fix potential NULL dereference in sprd_dma_probe()
@ 2018-05-07 1:40 ` Wei Yongjun
0 siblings, 0 replies; 14+ messages in thread
From: Wei Yongjun @ 2018-05-07 1:40 UTC (permalink / raw)
To: Dan Williams, Vinod Koul, Orson Zhai, Baolin Wang, Chunyan Zhang
Cc: Wei Yongjun, dmaengine, kernel-janitors
platform_get_resource() may fail and return NULL, so we should
better check it's return value to avoid a NULL pointer dereference
a bit later in the code.
This is detected by Coccinelle semantic patch.
@@
expression pdev, res, n, t, e, e1, e2;
@@
res = platform_get_resource(pdev, t, n);
+ if (!res)
+ return -EINVAL;
... when != res = NULL
e = devm_ioremap_nocache(e1, res->start, e2);
Fixes: 9b3b8171f7f4 ("dmaengine: sprd: Add Spreadtrum DMA driver")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
drivers/dma/sprd-dma.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
index ccdeb8f..dba7a17 100644
--- a/drivers/dma/sprd-dma.c
+++ b/drivers/dma/sprd-dma.c
@@ -807,6 +807,8 @@ static int sprd_dma_probe(struct platform_device *pdev)
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res)
+ return -EINVAL;
sdev->glb_base = devm_ioremap_nocache(&pdev->dev, res->start,
resource_size(res));
if (!sdev->glb_base)
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [-next] dmaengine: sprd: Fix potential NULL dereference in sprd_dma_probe()
2018-05-07 1:40 ` [PATCH -next] " Wei Yongjun
@ 2018-05-07 1:56 ` Baolin Wang
-1 siblings, 0 replies; 14+ messages in thread
From: Baolin Wang @ 2018-05-07 1:56 UTC (permalink / raw)
To: Wei Yongjun
Cc: Dan Williams, Vinod Koul, Orson Zhai, Chunyan Zhang, dmaengine,
kernel-janitors
Hi Yongjun,
On 7 May 2018 at 09:40, Wei Yongjun <weiyongjun1@huawei.com> wrote:
> platform_get_resource() may fail and return NULL, so we should
> better check it's return value to avoid a NULL pointer dereference
> a bit later in the code.
>
> This is detected by Coccinelle semantic patch.
>
> @@
> expression pdev, res, n, t, e, e1, e2;
> @@
>
> res = platform_get_resource(pdev, t, n);
> + if (!res)
> + return -EINVAL;
> ... when != res == NULL
> e = devm_ioremap_nocache(e1, res->start, e2);
>
> Fixes: 9b3b8171f7f4 ("dmaengine: sprd: Add Spreadtrum DMA driver")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Thanks for fixing my mistake.
Reviewed-by: Baolin Wang <baolin.wang@linaro.org>
> ---
> drivers/dma/sprd-dma.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
> index ccdeb8f..dba7a17 100644
> --- a/drivers/dma/sprd-dma.c
> +++ b/drivers/dma/sprd-dma.c
> @@ -807,6 +807,8 @@ static int sprd_dma_probe(struct platform_device *pdev)
> }
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!res)
> + return -EINVAL;
> sdev->glb_base = devm_ioremap_nocache(&pdev->dev, res->start,
> resource_size(res));
> if (!sdev->glb_base)
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH -next] dmaengine: sprd: Fix potential NULL dereference in sprd_dma_probe()
@ 2018-05-07 1:56 ` Baolin Wang
0 siblings, 0 replies; 14+ messages in thread
From: Baolin Wang @ 2018-05-07 1:56 UTC (permalink / raw)
To: Wei Yongjun
Cc: Dan Williams, Vinod Koul, Orson Zhai, Chunyan Zhang, dmaengine,
kernel-janitors
Hi Yongjun,
On 7 May 2018 at 09:40, Wei Yongjun <weiyongjun1@huawei.com> wrote:
> platform_get_resource() may fail and return NULL, so we should
> better check it's return value to avoid a NULL pointer dereference
> a bit later in the code.
>
> This is detected by Coccinelle semantic patch.
>
> @@
> expression pdev, res, n, t, e, e1, e2;
> @@
>
> res = platform_get_resource(pdev, t, n);
> + if (!res)
> + return -EINVAL;
> ... when != res = NULL
> e = devm_ioremap_nocache(e1, res->start, e2);
>
> Fixes: 9b3b8171f7f4 ("dmaengine: sprd: Add Spreadtrum DMA driver")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Thanks for fixing my mistake.
Reviewed-by: Baolin Wang <baolin.wang@linaro.org>
> ---
> drivers/dma/sprd-dma.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
> index ccdeb8f..dba7a17 100644
> --- a/drivers/dma/sprd-dma.c
> +++ b/drivers/dma/sprd-dma.c
> @@ -807,6 +807,8 @@ static int sprd_dma_probe(struct platform_device *pdev)
> }
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!res)
> + return -EINVAL;
> sdev->glb_base = devm_ioremap_nocache(&pdev->dev, res->start,
> resource_size(res));
> if (!sdev->glb_base)
>
--
Baolin.wang
Best Regards
^ permalink raw reply [flat|nested] 14+ messages in thread
* [-next] dmaengine: sprd: Fix potential NULL dereference in sprd_dma_probe()
2018-05-07 1:40 ` [PATCH -next] " Wei Yongjun
@ 2018-05-07 8:16 ` Vinod Koul
-1 siblings, 0 replies; 14+ messages in thread
From: Vinod Koul @ 2018-05-07 8:04 UTC (permalink / raw)
To: Wei Yongjun
Cc: Dan Williams, Vinod Koul, Orson Zhai, Baolin Wang, Chunyan Zhang,
dmaengine, kernel-janitors
On Mon, May 07, 2018 at 01:40:34AM +0000, Wei Yongjun wrote:
> platform_get_resource() may fail and return NULL, so we should
> better check it's return value to avoid a NULL pointer dereference
> a bit later in the code.
>
> This is detected by Coccinelle semantic patch.
Applied, thanks
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH -next] dmaengine: sprd: Fix potential NULL dereference in sprd_dma_probe()
@ 2018-05-07 8:16 ` Vinod Koul
0 siblings, 0 replies; 14+ messages in thread
From: Vinod Koul @ 2018-05-07 8:16 UTC (permalink / raw)
To: Wei Yongjun
Cc: Dan Williams, Vinod Koul, Orson Zhai, Baolin Wang, Chunyan Zhang,
dmaengine, kernel-janitors
On Mon, May 07, 2018 at 01:40:34AM +0000, Wei Yongjun wrote:
> platform_get_resource() may fail and return NULL, so we should
> better check it's return value to avoid a NULL pointer dereference
> a bit later in the code.
>
> This is detected by Coccinelle semantic patch.
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 14+ messages in thread
* [-next] dmaengine: sprd: Fix potential NULL dereference in sprd_dma_probe()
2018-05-07 1:40 ` [PATCH -next] " Wei Yongjun
@ 2018-05-08 11:46 ` Lars-Peter Clausen
-1 siblings, 0 replies; 14+ messages in thread
From: Lars-Peter Clausen @ 2018-05-08 11:46 UTC (permalink / raw)
To: Wei Yongjun, Dan Williams, Vinod Koul, Orson Zhai, Baolin Wang,
Chunyan Zhang
Cc: dmaengine, kernel-janitors
On 05/07/2018 03:40 AM, Wei Yongjun wrote:
> platform_get_resource() may fail and return NULL, so we should
> better check it's return value to avoid a NULL pointer dereference
> a bit later in the code.
>
> This is detected by Coccinelle semantic patch.
>
> @@
> expression pdev, res, n, t, e, e1, e2;
> @@
>
> res = platform_get_resource(pdev, t, n);
> + if (!res)
> + return -EINVAL;
> ... when != res == NULL
> e = devm_ioremap_nocache(e1, res->start, e2);
>
> Fixes: 9b3b8171f7f4 ("dmaengine: sprd: Add Spreadtrum DMA driver")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
> drivers/dma/sprd-dma.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
> index ccdeb8f..dba7a17 100644
> --- a/drivers/dma/sprd-dma.c
> +++ b/drivers/dma/sprd-dma.c
> @@ -807,6 +807,8 @@ static int sprd_dma_probe(struct platform_device *pdev)
> }
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!res)
> + return -EINVAL;
> sdev->glb_base = devm_ioremap_nocache(&pdev->dev, res->start,
> resource_size(res));
I think a better improvement would be to replace this with
devm_ioremap_resource() which has the NULL pointer check and some other
things built-in.
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH -next] dmaengine: sprd: Fix potential NULL dereference in sprd_dma_probe()
@ 2018-05-08 11:46 ` Lars-Peter Clausen
0 siblings, 0 replies; 14+ messages in thread
From: Lars-Peter Clausen @ 2018-05-08 11:46 UTC (permalink / raw)
To: Wei Yongjun, Dan Williams, Vinod Koul, Orson Zhai, Baolin Wang,
Chunyan Zhang
Cc: dmaengine, kernel-janitors
On 05/07/2018 03:40 AM, Wei Yongjun wrote:
> platform_get_resource() may fail and return NULL, so we should
> better check it's return value to avoid a NULL pointer dereference
> a bit later in the code.
>
> This is detected by Coccinelle semantic patch.
>
> @@
> expression pdev, res, n, t, e, e1, e2;
> @@
>
> res = platform_get_resource(pdev, t, n);
> + if (!res)
> + return -EINVAL;
> ... when != res = NULL
> e = devm_ioremap_nocache(e1, res->start, e2);
>
> Fixes: 9b3b8171f7f4 ("dmaengine: sprd: Add Spreadtrum DMA driver")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
> drivers/dma/sprd-dma.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
> index ccdeb8f..dba7a17 100644
> --- a/drivers/dma/sprd-dma.c
> +++ b/drivers/dma/sprd-dma.c
> @@ -807,6 +807,8 @@ static int sprd_dma_probe(struct platform_device *pdev)
> }
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!res)
> + return -EINVAL;
> sdev->glb_base = devm_ioremap_nocache(&pdev->dev, res->start,
> resource_size(res));
I think a better improvement would be to replace this with
devm_ioremap_resource() which has the NULL pointer check and some other
things built-in.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [-next] dmaengine: sprd: Fix potential NULL dereference in sprd_dma_probe()
2018-05-07 1:40 ` [PATCH -next] " Wei Yongjun
@ 2018-05-08 12:17 ` Vinod Koul
-1 siblings, 0 replies; 14+ messages in thread
From: Vinod Koul @ 2018-05-08 12:05 UTC (permalink / raw)
To: Lars-Peter Clausen
Cc: Wei Yongjun, Dan Williams, Vinod Koul, Orson Zhai, Baolin Wang,
Chunyan Zhang, dmaengine, kernel-janitors
On 08-05-18, 13:46, Lars-Peter Clausen wrote:
> On 05/07/2018 03:40 AM, Wei Yongjun wrote:
> > res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > + if (!res)
> > + return -EINVAL;
> > sdev->glb_base = devm_ioremap_nocache(&pdev->dev, res->start,
> > resource_size(res));
>
> I think a better improvement would be to replace this with
> devm_ioremap_resource() which has the NULL pointer check and some other
> things built-in.
Sure feel free to send a patch :)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [-next] dmaengine: sprd: Fix potential NULL dereference in sprd_dma_probe()
2018-05-07 1:40 ` [PATCH -next] " Wei Yongjun
@ 2018-05-08 12:10 ` Lars-Peter Clausen
-1 siblings, 0 replies; 14+ messages in thread
From: Lars-Peter Clausen @ 2018-05-08 12:10 UTC (permalink / raw)
To: Vinod Koul
Cc: Wei Yongjun, Dan Williams, Vinod Koul, Orson Zhai, Baolin Wang,
Chunyan Zhang, dmaengine, kernel-janitors
On 05/08/2018 02:05 PM, Vinod Koul wrote:
> On 08-05-18, 13:46, Lars-Peter Clausen wrote:
>> On 05/07/2018 03:40 AM, Wei Yongjun wrote:
>>> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>> + if (!res)
>>> + return -EINVAL;
>>> sdev->glb_base = devm_ioremap_nocache(&pdev->dev, res->start,
>>> resource_size(res));
>>
>> I think a better improvement would be to replace this with
>> devm_ioremap_resource() which has the NULL pointer check and some other
>> things built-in.
>
> Sure feel free to send a patch :)
>
I prefer to inspire others ;)
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH -next] dmaengine: sprd: Fix potential NULL dereference in sprd_dma_probe()
@ 2018-05-08 12:10 ` Lars-Peter Clausen
0 siblings, 0 replies; 14+ messages in thread
From: Lars-Peter Clausen @ 2018-05-08 12:10 UTC (permalink / raw)
To: Vinod Koul
Cc: Wei Yongjun, Dan Williams, Vinod Koul, Orson Zhai, Baolin Wang,
Chunyan Zhang, dmaengine, kernel-janitors
On 05/08/2018 02:05 PM, Vinod Koul wrote:
> On 08-05-18, 13:46, Lars-Peter Clausen wrote:
>> On 05/07/2018 03:40 AM, Wei Yongjun wrote:
>>> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>> + if (!res)
>>> + return -EINVAL;
>>> sdev->glb_base = devm_ioremap_nocache(&pdev->dev, res->start,
>>> resource_size(res));
>>
>> I think a better improvement would be to replace this with
>> devm_ioremap_resource() which has the NULL pointer check and some other
>> things built-in.
>
> Sure feel free to send a patch :)
>
I prefer to inspire others ;)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH -next] dmaengine: sprd: Fix potential NULL dereference in sprd_dma_probe()
@ 2018-05-08 12:17 ` Vinod Koul
0 siblings, 0 replies; 14+ messages in thread
From: Vinod Koul @ 2018-05-08 12:17 UTC (permalink / raw)
To: Lars-Peter Clausen
Cc: Wei Yongjun, Dan Williams, Vinod Koul, Orson Zhai, Baolin Wang,
Chunyan Zhang, dmaengine, kernel-janitors
On 08-05-18, 13:46, Lars-Peter Clausen wrote:
> On 05/07/2018 03:40 AM, Wei Yongjun wrote:
> > res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > + if (!res)
> > + return -EINVAL;
> > sdev->glb_base = devm_ioremap_nocache(&pdev->dev, res->start,
> > resource_size(res));
>
> I think a better improvement would be to replace this with
> devm_ioremap_resource() which has the NULL pointer check and some other
> things built-in.
Sure feel free to send a patch :)
--
~Vinod
^ permalink raw reply [flat|nested] 14+ messages in thread
* [-next] dmaengine: sprd: Fix potential NULL dereference in sprd_dma_probe()
2018-05-07 1:40 ` [PATCH -next] " Wei Yongjun
@ 2018-05-09 1:29 ` Baolin Wang
-1 siblings, 0 replies; 14+ messages in thread
From: Baolin Wang @ 2018-05-09 1:29 UTC (permalink / raw)
To: Lars-Peter Clausen
Cc: Vinod Koul, Wei Yongjun, Dan Williams, Vinod Koul, Orson Zhai,
Chunyan Zhang, dmaengine, kernel-janitors
On 8 May 2018 at 20:10, Lars-Peter Clausen <lars@metafoo.de> wrote:
> On 05/08/2018 02:05 PM, Vinod Koul wrote:
>> On 08-05-18, 13:46, Lars-Peter Clausen wrote:
>>> On 05/07/2018 03:40 AM, Wei Yongjun wrote:
>>>> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>> + if (!res)
>>>> + return -EINVAL;
>>>> sdev->glb_base = devm_ioremap_nocache(&pdev->dev, res->start,
>>>> resource_size(res));
>>>
>>> I think a better improvement would be to replace this with
>>> devm_ioremap_resource() which has the NULL pointer check and some other
>>> things built-in.
>>
>> Sure feel free to send a patch :)
>>
>
> I prefer to inspire others ;)
OK. I will send one incremental patch to fix this issue. Thanks.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH -next] dmaengine: sprd: Fix potential NULL dereference in sprd_dma_probe()
@ 2018-05-09 1:29 ` Baolin Wang
0 siblings, 0 replies; 14+ messages in thread
From: Baolin Wang @ 2018-05-09 1:29 UTC (permalink / raw)
To: Lars-Peter Clausen
Cc: Vinod Koul, Wei Yongjun, Dan Williams, Vinod Koul, Orson Zhai,
Chunyan Zhang, dmaengine, kernel-janitors
On 8 May 2018 at 20:10, Lars-Peter Clausen <lars@metafoo.de> wrote:
> On 05/08/2018 02:05 PM, Vinod Koul wrote:
>> On 08-05-18, 13:46, Lars-Peter Clausen wrote:
>>> On 05/07/2018 03:40 AM, Wei Yongjun wrote:
>>>> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>> + if (!res)
>>>> + return -EINVAL;
>>>> sdev->glb_base = devm_ioremap_nocache(&pdev->dev, res->start,
>>>> resource_size(res));
>>>
>>> I think a better improvement would be to replace this with
>>> devm_ioremap_resource() which has the NULL pointer check and some other
>>> things built-in.
>>
>> Sure feel free to send a patch :)
>>
>
> I prefer to inspire others ;)
OK. I will send one incremental patch to fix this issue. Thanks.
--
Baolin.wang
Best Regards
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2018-05-09 1:29 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-07 8:04 [-next] dmaengine: sprd: Fix potential NULL dereference in sprd_dma_probe() Vinod Koul
2018-05-07 8:16 ` [PATCH -next] " Vinod Koul
-- strict thread matches above, loose matches on Subject: below --
2018-05-09 1:29 [-next] " Baolin Wang
2018-05-09 1:29 ` [PATCH -next] " Baolin Wang
2018-05-08 12:10 [-next] " Lars-Peter Clausen
2018-05-08 12:10 ` [PATCH -next] " Lars-Peter Clausen
2018-05-08 12:05 [-next] " Vinod Koul
2018-05-08 12:17 ` [PATCH -next] " Vinod Koul
2018-05-08 11:46 [-next] " Lars-Peter Clausen
2018-05-08 11:46 ` [PATCH -next] " Lars-Peter Clausen
2018-05-07 1:56 [-next] " Baolin Wang
2018-05-07 1:56 ` [PATCH -next] " Baolin Wang
2018-05-07 1:40 [-next] " weiyongjun (A)
2018-05-07 1:40 ` [PATCH -next] " Wei Yongjun
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.