From: Jingoo Han <jg1.han@samsung.com>
To: "'Rickard Strandqvist'" <rickard_strandqvist@spectrumdigital.se>,
"'Wolfram Sang'" <wsa@the-dreams.de>
Cc: "'Grant Likely'" <grant.likely@linaro.org>,
"'Rob Herring'" <robh+dt@kernel.org>,
"'Leilei Shang'" <shangll@marvell.com>,
"'Daniel Drake'" <dsd@laptop.org>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org, "'Jingoo Han'" <jg1.han@samsung.com>
Subject: Re: [PATCH] i2c: busses: i2c-pxa.c: Fix for possible null pointer dereference
Date: Mon, 02 Jun 2014 10:55:43 +0900 [thread overview]
Message-ID: <004801cf7e05$c3354c20$499fe460$%han@samsung.com> (raw)
In-Reply-To: <20140601202647.GD3853@katana>
On Monday, June 02, 2014 5:27 AM, Wolfram Sang wrote:
> On Sat, May 17, 2014 at 07:14:08PM +0200, Rickard Strandqvist wrote:
> > There is otherwise a risk of a possible null pointer dereference.
> >
> > Was largely found by using a static code analysis program called cppcheck.
>
> It is useful to put the output of the analyzer here.
>
> >
> > Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> > ---
> > drivers/i2c/busses/i2c-pxa.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
> > index bbe6dfb..dbe5ebe 100644
> > --- a/drivers/i2c/busses/i2c-pxa.c
> > +++ b/drivers/i2c/busses/i2c-pxa.c
> > @@ -1269,7 +1269,9 @@ eremap:
> > eclk:
> > kfree(i2c);
> > emalloc:
> > - release_mem_region(res->start, resource_size(res));
> > + if(res) {
> > + release_mem_region(res->start, resource_size(res));
> > + }
>
> The proper fix is to move the release to the proper place, before kfree.
> Even better would probably be a devm_* conversion.
+1
I agree with Wolfram Sang's opinion. Please call release_mem_region()
prior to kfree().
One more thing, don't use braces when a single statement
is used. Please refer to 'Chapter 3: Placing Braces and Spaces'
of 'Documentation/CodingStyle'.
Best regards,
Jingoo Han
prev parent reply other threads:[~2014-06-02 1:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-17 17:14 Rickard Strandqvist
2014-05-17 17:18 ` Mateusz Guzik
2014-06-01 20:26 ` Wolfram Sang
2014-06-02 1:55 ` Jingoo Han [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='004801cf7e05$c3354c20$499fe460$%han@samsung.com' \
--to=jg1.han@samsung.com \
--cc=devicetree@vger.kernel.org \
--cc=dsd@laptop.org \
--cc=grant.likely@linaro.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rickard_strandqvist@spectrumdigital.se \
--cc=robh+dt@kernel.org \
--cc=shangll@marvell.com \
--cc=wsa@the-dreams.de \
/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®