From: Dan Carpenter <dan.carpenter@oracle.com>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3] ARM: imx: fix error handling in ipu device registration
Date: Sat, 17 May 2014 22:53:39 +0000 [thread overview]
Message-ID: <20140517225339.GJ16255@mwanda> (raw)
In-Reply-To: <20140517223555.GR3693@n2100.arm.linux.org.uk>
On Sat, May 17, 2014 at 11:35:55PM +0100, Russell King - ARM Linux wrote:
> On Sun, May 18, 2014 at 01:08:36AM +0300, Dan Carpenter wrote:
> > Let's look at that error handling again.
> >
> > err: <-- the name is not descriptive. the location is bad.
> > kfree(pdev->dev.dma_mask); <- null dereference.
> > platform_device_put(pdev); <- ok
> > return ERR_PTR(-ENODEV); <- should be "return ERR_PTR(ret);"
> >
> > 3 out of 4 of the lines are bad.
>
> 2 out of 4. kfree(NULL) is perfectly legal.
pdev was NULL though...
The bug is *caused* by trying to use the same "err" label to do all
error handling. This is a very common anti-patern, but if you follow
canonical kernel style then your error handling is less buggy.
regards,
dan carpenter
WARNING: multiple messages have this Message-ID (diff)
From: dan.carpenter@oracle.com (Dan Carpenter)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3] ARM: imx: fix error handling in ipu device registration
Date: Sun, 18 May 2014 01:53:39 +0300 [thread overview]
Message-ID: <20140517225339.GJ16255@mwanda> (raw)
In-Reply-To: <20140517223555.GR3693@n2100.arm.linux.org.uk>
On Sat, May 17, 2014 at 11:35:55PM +0100, Russell King - ARM Linux wrote:
> On Sun, May 18, 2014 at 01:08:36AM +0300, Dan Carpenter wrote:
> > Let's look at that error handling again.
> >
> > err: <-- the name is not descriptive. the location is bad.
> > kfree(pdev->dev.dma_mask); <- null dereference.
> > platform_device_put(pdev); <- ok
> > return ERR_PTR(-ENODEV); <- should be "return ERR_PTR(ret);"
> >
> > 3 out of 4 of the lines are bad.
>
> 2 out of 4. kfree(NULL) is perfectly legal.
pdev was NULL though...
The bug is *caused* by trying to use the same "err" label to do all
error handling. This is a very common anti-patern, but if you follow
canonical kernel style then your error handling is less buggy.
regards,
dan carpenter
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Emil Goode" <emilgoode@gmail.com>,
"Shawn Guo" <shawn.guo@freescale.com>,
"Sascha Hauer" <kernel@pengutronix.de>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH v3] ARM: imx: fix error handling in ipu device registration
Date: Sun, 18 May 2014 01:53:39 +0300 [thread overview]
Message-ID: <20140517225339.GJ16255@mwanda> (raw)
In-Reply-To: <20140517223555.GR3693@n2100.arm.linux.org.uk>
On Sat, May 17, 2014 at 11:35:55PM +0100, Russell King - ARM Linux wrote:
> On Sun, May 18, 2014 at 01:08:36AM +0300, Dan Carpenter wrote:
> > Let's look at that error handling again.
> >
> > err: <-- the name is not descriptive. the location is bad.
> > kfree(pdev->dev.dma_mask); <- null dereference.
> > platform_device_put(pdev); <- ok
> > return ERR_PTR(-ENODEV); <- should be "return ERR_PTR(ret);"
> >
> > 3 out of 4 of the lines are bad.
>
> 2 out of 4. kfree(NULL) is perfectly legal.
pdev was NULL though...
The bug is *caused* by trying to use the same "err" label to do all
error handling. This is a very common anti-patern, but if you follow
canonical kernel style then your error handling is less buggy.
regards,
dan carpenter
next prev parent reply other threads:[~2014-05-17 22:53 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-17 18:40 [PATCH v3] ARM: imx: fix error handling in ipu device registration Emil Goode
2014-05-17 18:40 ` Emil Goode
2014-05-17 18:40 ` Emil Goode
2014-05-17 19:18 ` Uwe Kleine-König
2014-05-17 19:18 ` Uwe Kleine-König
2014-05-17 19:18 ` Uwe Kleine-König
2014-05-17 22:08 ` Dan Carpenter
2014-05-17 22:08 ` Dan Carpenter
2014-05-17 22:08 ` Dan Carpenter
2014-05-17 22:35 ` Russell King - ARM Linux
2014-05-17 22:35 ` Russell King - ARM Linux
2014-05-17 22:35 ` Russell King - ARM Linux
2014-05-17 22:53 ` Dan Carpenter [this message]
2014-05-17 22:53 ` Dan Carpenter
2014-05-17 22:53 ` Dan Carpenter
2014-05-17 22:57 ` Emil Goode
2014-05-17 22:57 ` Emil Goode
2014-05-17 22:57 ` Emil Goode
2014-05-17 22:51 ` Emil Goode
2014-05-17 22:51 ` Emil Goode
2014-05-17 22:51 ` Emil Goode
2014-05-17 22:22 ` Emil Goode
2014-05-17 22:22 ` Emil Goode
2014-05-17 22:22 ` Emil Goode
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=20140517225339.GJ16255@mwanda \
--to=dan.carpenter@oracle.com \
--cc=linux-arm-kernel@lists.infradead.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.