From: Samuel Ortiz <sameo@linux.intel.com>
To: Axel Lin <axel.lin@gmail.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>
Subject: Re: [PATCH 1/2] jz4740-adc/jz4740-hwmon: check kmalloc() result
Date: Mon, 2 Aug 2010 00:41:06 +0200 [thread overview]
Message-ID: <20100801224105.GB3052@sortiz-mobl> (raw)
In-Reply-To: <1280391953.21676.2.camel@mola>
Hi Axel,
On Thu, Jul 29, 2010 at 04:25:53PM +0800, Axel Lin wrote:
> If kmalloc() fails, exit with -ENOMEM.
Could you please separate this patch in 2, as the 2 drivers live in different
trees for now ?
Cheers,
Samuel.
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
> This patch is against linux-next.
> drivers/hwmon/jz4740-hwmon.c | 4 ++++
> drivers/mfd/jz4740-adc.c | 4 ++++
> 2 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/hwmon/jz4740-hwmon.c b/drivers/hwmon/jz4740-hwmon.c
> index 72a4335..1c8b3d9 100644
> --- a/drivers/hwmon/jz4740-hwmon.c
> +++ b/drivers/hwmon/jz4740-hwmon.c
> @@ -107,6 +107,10 @@ static int __devinit jz4740_hwmon_probe(struct platform_device *pdev)
> struct jz4740_hwmon *hwmon;
>
> hwmon = kmalloc(sizeof(*hwmon), GFP_KERNEL);
> + if (!hwmon) {
> + dev_err(&pdev->dev, "Failed to allocate driver structure\n");
> + return -ENOMEM;
> + }
>
> hwmon->cell = pdev->dev.platform_data;
>
> diff --git a/drivers/mfd/jz4740-adc.c b/drivers/mfd/jz4740-adc.c
> index 7a844ae..2846d24 100644
> --- a/drivers/mfd/jz4740-adc.c
> +++ b/drivers/mfd/jz4740-adc.c
> @@ -260,6 +260,10 @@ static int __devinit jz4740_adc_probe(struct platform_device *pdev)
> int irq;
>
> adc = kmalloc(sizeof(*adc), GFP_KERNEL);
> + if (!adc) {
> + dev_err(&pdev->dev, "Failed to allocate driver structure\n");
> + return -ENOMEM;
> + }
>
> adc->irq = platform_get_irq(pdev, 0);
> if (adc->irq < 0) {
> --
> 1.5.4.3
>
>
>
--
Intel Open Source Technology Centre
http://oss.intel.com/
prev parent reply other threads:[~2010-08-01 22:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-29 8:25 Axel Lin
2010-08-01 22:41 ` Samuel Ortiz [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=20100801224105.GB3052@sortiz-mobl \
--to=sameo@linux.intel.com \
--cc=axel.lin@gmail.com \
--cc=lars@metafoo.de \
--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 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®