mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: 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, 1 reply; 4+ messages in thread
From: Jiasheng Jiang @ 2022-01-07  6:28 UTC (permalink / raw)
  To: damien.lemoal, davem; +Cc: linux-ide, linux-kernel, Jiasheng Jiang

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


^ permalink raw reply	[flat|nested] 4+ messages in thread
* [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; 4+ 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	[flat|nested] 4+ messages in thread

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07  6:28 Re: [PATCH] ide: Check for null pointer after calling devm_ioremap Jiasheng Jiang
2022-01-07  6:41 ` Damien Le Moal
  -- strict thread matches above, loose matches on Subject: below --
2022-01-07  3:17 Jiasheng Jiang
2022-01-07  5:30 ` 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

all inboxes | Powered by JetHome®