[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <087ac312-1d73-4721-f17f-af48b6ea65a2@opensource.wdc.com>
Date: Fri, 7 Jan 2022 14:30:35 +0900
From: Damien Le Moal <damien.lemoal@...nsource.wdc.com>
To: Jiasheng Jiang <jiasheng@...as.ac.cn>, davem@...emloft.net
Cc: linux-ide@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ide: Check for null pointer after calling devm_ioremap
On 2022/01/07 12:17, Jiasheng Jiang wrote:
> As the possible failure of the devres_alloc(), the devm_ioremap() and
> devm_ioport_map() may return NULL pointer.
> And then, the 'base' and 'alt_base' is used in plat_ide_setup_ports().
> Therefore, it should be better to add the check in order to avoid the
> dereference of the NULL pointer.
>
> Fixes: 2bfba3c444fe ("ide: remove useless subdirs from drivers/ide/")
> Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
> ---
> drivers/ide/ide_platform.c | 4 ++++
There is no such file... What kernel is this patch against ?
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/ide/ide_platform.c b/drivers/ide/ide_platform.c
> index 91639fd6c276..8c6e1af7b6eb 100644
> --- a/drivers/ide/ide_platform.c
> +++ b/drivers/ide/ide_platform.c
> @@ -85,6 +85,10 @@ static int plat_ide_probe(struct platform_device *pdev)
> alt_base = devm_ioport_map(&pdev->dev,
> res_alt->start, resource_size(res_alt));
> }
> + if (!base || !alt_base) {
> + ret = -ENOMEM;
> + goto out;
> + }
>
> memset(&hw, 0, sizeof(hw));
> plat_ide_setup_ports(&hw, base, alt_base, pdata, res_irq->start);
--
Damien Le Moal
Western Digital Research
Powered by blists - more mailing lists