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 <[email protected]>
---
drivers/ide/ide_platform.c | 4 ++++
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);
--
2.25.1
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 <[email protected]>
> ---
> 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
On Fri, Jan 07, 2022 at 01:30:35PM +0800, Damien Le Moal wrote:
> There is no such file... What kernel is this patch against ?
Thanks, this patch is based on linux-stable-5.13.9.
And I just notice that in Jun 16 2021, this file was removed.
Anyway, this patch can be applied to the previous version, which still
has the `drivers/ide/ide_platform.c`.
Sincerely thanks,
Jiang
On 2022/01/07 15:28, Jiasheng Jiang wrote:
> On Fri, Jan 07, 2022 at 01:30:35PM +0800, Damien Le Moal wrote:
>> There is no such file... What kernel is this patch against ?
>
> Thanks, this patch is based on linux-stable-5.13.9.
> And I just notice that in Jun 16 2021, this file was removed.
> Anyway, this patch can be applied to the previous version, which still
> has the `drivers/ide/ide_platform.c`.
Kernel 5.13 is EOL. No new patches are applied to this kernel. If you need this
fixed, then please check the latest kernel first and mark the patch for
backporting (fixes + cc: stable tags) to the latest stable (5.15) and LTS
kernels (5.15, 5.10 etc).
>
> Sincerely thanks,
> Jiang
>
--
Damien Le Moal
Western Digital Research