[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8eacbd27239ec5ce956309278beae9b499499108.camel@perches.com>
Date: Fri, 14 Jun 2019 03:04:19 -0700
From: Joe Perches <joe@...ches.com>
To: John Garry <john.garry@...wei.com>, xuwei5@...wei.com
Cc: bhelgaas@...gle.com, linuxarm@...wei.com, arm@...nel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] bus: hisi_lpc: Don't use devm_kzalloc() to allocate
logical PIO range
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@...wei.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.
Powered by blists - more mailing lists