mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Jiasheng Jiang <jiasheng@iscas.ac.cn>, davem@davemloft.net
Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] ide: Check for null pointer after calling devm_ioremap
Date: Fri, 7 Jan 2022 16:43:16 +0900	[thread overview]
Message-ID: <e592bbde-0e74-4f7c-9ffc-6b04b90d12ad@opensource.wdc.com> (raw)
In-Reply-To: <20220107070404.3611861-1-jiasheng@iscas.ac.cn>

On 1/7/22 16:04, 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/")

This patch only renamed files under drivers/ide. I do not think it is
the patch that introduced the problem you are trying to fix.

> Cc: 5.10

Please read
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html?highlight=linux%20stable

> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> Changelog
> 
> v1 -> v2
> 
> * Change 1. Add cc.

Adding a CC to the distribution list of the patch does not change the
patch itself, so no need for tagging "v2".

> ---
>  drivers/ide/ide_platform.c | 4 ++++

Again, this file does NOT exist anymore.
The legacy IDE driver was removed from the kernel with version 5.14 by
commit b7fb14d3ac63 ("ide: remove the legacy ide driver"). libata now
implements drivers for legacy PATA/IDE drives. Have you checked first if
your fix is needed there ? If it is, then please send your patch against
the current libata tree. If the fix is needed only in older LTS kernels,
then please make that clear in a cover letter with your patch.

>  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

  reply	other threads:[~2022-01-07  7:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-07  7:04 Jiasheng Jiang
2022-01-07  7:43 ` Damien Le Moal [this message]
2022-01-07  9:11 Jiasheng Jiang
2022-01-07  9:28 ` David Laight

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e592bbde-0e74-4f7c-9ffc-6b04b90d12ad@opensource.wdc.com \
    --to=damien.lemoal@opensource.wdc.com \
    --cc=davem@davemloft.net \
    --cc=jiasheng@iscas.ac.cn \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®