From: Vladimir Zapolskiy <vz@mleia.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] misc: sram: fix check of devm_ioremap*() return value
Date: Mon, 18 Apr 2016 04:12:18 +0300 [thread overview]
Message-ID: <57143472.8080100@mleia.com> (raw)
In-Reply-To: <1458701565-10722-1-git-send-email-vz@mleia.com>
Hi Greg,
On 23.03.2016 04:52, Vladimir Zapolskiy wrote:
> Both devm_ioremap() and devm_ioremap_wc() functions return either
> a pointer to valid iomem region or NULL, check for IS_ERR() is improper
> and may result in oops on error path. Now on error -ENOMEM is returned.
>
> Fixes: 0ab163ad1ea0 ("misc: sram: switch to ioremap_wc from ioremap")
> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
> ---
> I add Fixes: tag for reference, but unfortunately the change can not
> be cleanly applied to kernel versions liable to the problem.
>
> Changes from v1 to v2:
> - had to rebase on top of eb43e023130b ("misc: sram: add optional ioremap without write combining")
> - slightly reworded the commit message and subject
>
> v1 of the change: https://lkml.org/lkml/2016/3/6/202
>
this is a trivial fix of a potential NULL pointer dereference,
do you have any review comments?
> drivers/misc/sram.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
> index 69cdabe..f84b53d 100644
> --- a/drivers/misc/sram.c
> +++ b/drivers/misc/sram.c
> @@ -364,8 +364,8 @@ static int sram_probe(struct platform_device *pdev)
> sram->virt_base = devm_ioremap(sram->dev, res->start, size);
> else
> sram->virt_base = devm_ioremap_wc(sram->dev, res->start, size);
> - if (IS_ERR(sram->virt_base))
> - return PTR_ERR(sram->virt_base);
> + if (!sram->virt_base)
> + return -ENOMEM;
>
> sram->pool = devm_gen_pool_create(sram->dev, ilog2(SRAM_GRANULARITY),
> NUMA_NO_NODE, NULL);
>
--
With best wishes,
Vladimir
prev parent reply other threads:[~2016-04-18 1:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-23 2:52 [PATCH v2] misc: sram: fix check of devm_ioremap*() return value Vladimir Zapolskiy
2016-04-18 1:12 ` Vladimir Zapolskiy [this message]
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=57143472.8080100@mleia.com \
--to=vz@mleia.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.