Skip to content

Commit

Permalink
mmc: sh_mmcif: Check for null res pointer
Browse files Browse the repository at this point in the history
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'.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Cc: stable@vger.kernel.org # v5.16+
Link: https://lore.kernel.org/r/20220119120006.1426964-1-jiasheng@iscas.ac.cn
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
  • Loading branch information
Jiasheng Jiang authored and Ulf Hansson committed Jan 24, 2022
1 parent 40c67c2 commit 4d31535
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/mmc/host/sh_mmcif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4d31535

Please sign in to comment.