* [PATCH] mmc: sh_mmcif: Check for null res pointer
@ 2022-01-05 9:41 Jiasheng Jiang
2022-01-18 18:13 ` Ulf Hansson
0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2022-01-05 9:41 UTC (permalink / raw)
To: ulf.hansson; +Cc: linux-mmc, linux-kernel, Jiasheng Jiang
If there is no suitable resource, platform_get_resource() will return
NULL.
Therefore in order to avoid the dereference of the NULL pointer, it
should be better to check the 'res'.
Fixes: 27cbd7e815a8 ("mmc: sh_mmcif: rework dma channel handling")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
drivers/mmc/host/sh_mmcif.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index e5e457037235..45dfa3b0be9c 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -405,6 +405,9 @@ static int sh_mmcif_dma_slave_config(struct sh_mmcif_host *host,
struct dma_slave_config cfg = { 0, };
res = platform_get_resource(host->pd, IORESOURCE_MEM, 0);
+ if (!res)
+ return -EINVAL;
+
cfg.direction = direction;
if (direction == DMA_DEV_TO_MEM) {
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mmc: sh_mmcif: Check for null res pointer
2022-01-05 9:41 [PATCH] mmc: sh_mmcif: Check for null res pointer Jiasheng Jiang
@ 2022-01-18 18:13 ` Ulf Hansson
0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2022-01-18 18:13 UTC (permalink / raw)
To: Jiasheng Jiang; +Cc: linux-mmc, linux-kernel
On Wed, 5 Jan 2022 at 10:41, Jiasheng Jiang <jiasheng@iscas.ac.cn> wrote:
>
> If there is no suitable resource, platform_get_resource() will return
> NULL.
> Therefore in order to avoid the dereference of the NULL pointer, it
> should be better to check the 'res'.
>
> Fixes: 27cbd7e815a8 ("mmc: sh_mmcif: rework dma channel handling")
I think this fixes tag is wrong. The problem seems to have been there
way before this point.
I suggest we instead just tag it for stable - and then let it be
applied to whatever kernel version it can. Does it make sense to you?
Kind regards
Uffe
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> drivers/mmc/host/sh_mmcif.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
> index e5e457037235..45dfa3b0be9c 100644
> --- a/drivers/mmc/host/sh_mmcif.c
> +++ b/drivers/mmc/host/sh_mmcif.c
> @@ -405,6 +405,9 @@ static int sh_mmcif_dma_slave_config(struct sh_mmcif_host *host,
> struct dma_slave_config cfg = { 0, };
>
> res = platform_get_resource(host->pd, IORESOURCE_MEM, 0);
> + if (!res)
> + return -EINVAL;
> +
> cfg.direction = direction;
>
> if (direction == DMA_DEV_TO_MEM) {
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-18 18:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05 9:41 [PATCH] mmc: sh_mmcif: Check for null res pointer Jiasheng Jiang
2022-01-18 18:13 ` Ulf Hansson
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.