mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: John Garry <john.garry@huawei.com>, xuwei5@huawei.com
Cc: bhelgaas@google.com, linuxarm@huawei.com, arm@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bus: hisi_lpc: Don't use devm_kzalloc() to allocate logical PIO range
Date: Fri, 14 Jun 2019 03:04:19 -0700	[thread overview]
Message-ID: <8eacbd27239ec5ce956309278beae9b499499108.camel@perches.com> (raw)
In-Reply-To: <1560505624-39955-1-git-send-email-john.garry@huawei.com>

On Fri, 2019-06-14 at 17:47 +0800, John Garry wrote:
> If, after registering a logical PIO range, the driver probe later fails,
> the logical PIO range memory will be released automatically.
> 
> This causes an issue, in that the logical PIO range is not unregistered
> (that is not supported) and the released range memory may be later
> referenced
> 
> Allocate the logical PIO range with kzalloc() to avoid this potential
> issue.
> 
> Fixes: adf38bb0b5956 ("HISI LPC: Support the LPC host on Hip06/Hip07 with DT bindings")
> Signed-off-by: John Garry <john.garry@huawei.com>
> 
> diff --git a/drivers/bus/hisi_lpc.c b/drivers/bus/hisi_lpc.c
[]
> @@ -599,7 +599,7 @@ static int hisi_lpc_probe(struct platform_device *pdev)
>  	if (IS_ERR(lpcdev->membase))
>  		return PTR_ERR(lpcdev->membase);
>  
> -	range = devm_kzalloc(dev, sizeof(*range), GFP_KERNEL);
> +	range = kzalloc(sizeof(*range), GFP_KERNEL);

If this is really necessary, it'd be useful to say so in the
code too with a comment so it doesn't get drive-by 'unfixed'
by someone well meaning but ill-uninformed.



  reply	other threads:[~2019-06-14 10:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-14  9:47 John Garry
2019-06-14 10:04 ` Joe Perches [this message]
2019-06-14 10:07   ` John Garry

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=8eacbd27239ec5ce956309278beae9b499499108.camel@perches.com \
    --to=joe@perches.com \
    --cc=arm@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=john.garry@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=xuwei5@huawei.com \
    /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®