All of lore.kernel.org
 help / color / mirror / Atom feed
From: jonghwa3.lee@samsung.com
To: David Rientjes <rientjes@google.com>
Cc: linux-kernel@vger.kernel.org,
	Samuel Oritz <sameo@linux.intel.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Liam Gridwodd <lrg@ti.com>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	MyungJoo Ham <myungjoo.ham@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Chiwoong Byun <woong.byun@samsung.com>
Subject: Re: [PATCH v4 2/3] regulator: MAX77686: Add Maxim 77686 regulator driver
Date: Tue, 22 May 2012 13:36:39 +0900	[thread overview]
Message-ID: <4FBB17D7.8080107@samsung.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1205211404350.15733@chino.kir.corp.google.com>

On 2012년 05월 22일 06:06, David Rientjes wrote:

> On Mon, 21 May 2012, Jonghwa Lee wrote:
>> +static __devinit int max77686_pmic_probe(struct platform_device *pdev)
>> +{
>> +	struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
>> +	struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev);
>> +	struct regulator_dev **rdev;
>> +	struct max77686_data *max77686;
>> +	struct regulator_init_data **init_data;
>> +	int i, size;
>> +	int ret = 0;
>> +	struct regulator_config config;
>> +	unsigned int data = 0;
>> +
>> +	dev_dbg(&pdev->dev, "%s\n", __func__);
>> +
>> +	max77686 = devm_kzalloc(&pdev->dev, sizeof(struct max77686_data),
>> +				GFP_KERNEL);
>> +	if (!max77686)
>> +		return -ENOMEM;
>> +
>> +	size = sizeof(struct regulator_dev *) * MAX77686_REGULATORS;
>> +	max77686->rdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
>> +	if (!max77686->rdev)
>> +		return -ENOMEM;
> 
> Does this leak max77686?
>


It uses devm_kzalloc which automatically frees memory allocation when
the driver is detached. So we don't need to worry about it.

 
>> +
>> +	rdev = max77686->rdev;
>> +	max77686->dev = &pdev->dev;
>> +	max77686->iodev = iodev;
>> +	if (pdata)
>> +		max77686->num_regulators = pdata->num_regulators;
>> +	platform_set_drvdata(pdev, max77686);
>> +	init_data = devm_kzalloc(&pdev->dev,
>> +				sizeof(struct regulator_init_data *)
>> +					 * MAX77686_REGULATORS, GFP_KERNEL);
> 
> No error handling, which will cause a NULL pointer later when you use this 
> array.
> 


Okay, now i applied it.

> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 


Thanks and Regard

  reply	other threads:[~2012-05-22  4:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21  9:51 [PATCH v4 0/3] Add initial support for MAXIM 77686 mfd chip Jonghwa Lee
2012-05-21  9:51 ` [PATCH v4 1/3] mfd: MAX77686: Add Maxim 77686 mfd driver Jonghwa Lee
2012-05-22 21:57   ` Samuel Ortiz
2012-05-23  0:03     ` jonghwa3.lee
2012-06-06  5:53     ` Yadwinder Singh Brar
2012-06-25  8:37   ` Samuel Ortiz
2012-05-21  9:51 ` [PATCH v4 2/3] regulator: MAX77686: Add Maxim 77686 regulator driver Jonghwa Lee
2012-05-21 21:06   ` David Rientjes
2012-05-22  4:36     ` jonghwa3.lee [this message]
2012-05-21  9:51 ` [PATCH v4 3/3] rtc: MAX77686: Add Maxim 77686 rtc driver Jonghwa Lee

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=4FBB17D7.8080107@samsung.com \
    --to=jonghwa3.lee@samsung.com \
    --cc=a.zummo@towertech.it \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=cw00.choi@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.com \
    --cc=myungjoo.ham@samsung.com \
    --cc=rientjes@google.com \
    --cc=sameo@linux.intel.com \
    --cc=woong.byun@samsung.com \
    /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.