linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ide: Check for null pointer after calling devm_ioremap
@ 2022-01-07  3:17 Jiasheng Jiang
  2022-01-07  5:30 ` Damien Le Moal
  0 siblings, 1 reply; 3+ messages in thread
From: Jiasheng Jiang @ 2022-01-07  3:17 UTC (permalink / raw)
  To: davem; +Cc: linux-ide, linux-kernel, Jiasheng Jiang

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@iscas.ac.cn>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ide: Check for null pointer after calling devm_ioremap
  2022-01-07  3:17 [PATCH] ide: Check for null pointer after calling devm_ioremap Jiasheng Jiang
@ 2022-01-07  5:30 ` Damien Le Moal
  0 siblings, 0 replies; 3+ messages in thread
From: Damien Le Moal @ 2022-01-07  5:30 UTC (permalink / raw)
  To: Jiasheng Jiang, davem; +Cc: linux-ide, linux-kernel

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@iscas.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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ide: Check for null pointer after calling devm_ioremap
  2022-01-07  6:28 Jiasheng Jiang
@ 2022-01-07  6:41 ` Damien Le Moal
  0 siblings, 0 replies; 3+ messages in thread
From: Damien Le Moal @ 2022-01-07  6:41 UTC (permalink / raw)
  To: Jiasheng Jiang, davem; +Cc: linux-ide, linux-kernel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-07  6:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07  3:17 [PATCH] ide: Check for null pointer after calling devm_ioremap Jiasheng Jiang
2022-01-07  5:30 ` Damien Le Moal
2022-01-07  6:28 Jiasheng Jiang
2022-01-07  6:41 ` Damien Le Moal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).