All of lore.kernel.org
 help / color / mirror / Atom feed
From: jonghwa3.lee@samsung.com
To: jonghwa3.lee@samsung.com
Cc: Mike Turquette <mturquette@linaro.org>,
	linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	H Hartley Sweeten <hsweeten@visionengravers.com>,
	MyungJoo Ham <myungjoo.ham@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>
Subject: Re: [PATCH v4] clock: max77686: Add driver for Maxim 77686 32KHz crystal oscillator
Date: Fri, 24 Aug 2012 17:12:26 +0900	[thread overview]
Message-ID: <5037376A.9000507@samsung.com> (raw)
In-Reply-To: <5037318E.2040903@samsung.com>

On 2012년 08월 24일 16:47, jonghwa3.lee@samsung.com wrote:
> On 2012년 08월 24일 11:07, Mike Turquette wrote:
>>> +       struct clk *clk;
>>> +
>>> +       clk = clk_register(dev, clk_name[clk_id], &clk_max77686_ops,
>>> +                               &max77686->hw, NULL, 0, CLK_IS_ROOT);
>>> +
>>> +       if (IS_ERR(clk))
>>> +               return -ENOMEM;
>>> +
>>> +       max77686->lookup = devm_kzalloc(dev, sizeof(struct clk_lookup),
>>> +                                       GFP_KERNEL);
>>> +       if (IS_ERR(max77686->lookup))
>>> +               return -ENOMEM;
>>> +
>>> +       max77686->lookup->con_id = clk_name[clk_id];
>>> +       max77686->lookup->clk = clk;
>>> +
>>> +       clkdev_add(max77686->lookup);
>>> +
>>> +       return 0;
>>> +}
>>> +
>>> +static __devinit int max77686_clk_probe(struct platform_device *pdev)
>>> +{
>>> +       struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
>>> +       struct clk_max77686 *max77686[MAX77686_CLKS_NUM];
>>> +       int i, ret;
>>> +
>>> +       for (i = 0; i < MAX77686_CLKS_NUM; i++) {
>>> +               max77686[i] = devm_kzalloc(&pdev->dev,
>>> +                                sizeof(struct clk_max77686), GFP_KERNEL);
>>> +               if (!max77686[i])
>>> +                       return -ENOMEM;
>>> +
>>> +               max77686[i]->iodev = iodev;
>>> +               max77686[i]->mask = 1 << i;
>>> +
>>> +               ret = max77686_clk_register(&pdev->dev, max77686[i], i);
>>> +               if (ret) {
>>> +                       dev_err(&pdev->dev, "Fail to register clock\n");
>>> +                       return ret;
>>> +               }
>> There is a memory leak if you successfully register any clocks and then
>> fail to register the others.  Be sure to unwind the loop and kfree those
>> clocks in such a case (since this appears fatal).
> I think it'll free memory allocation automatically, because It is used
> devm_kzalloc. Am I wrong?
>
>
Sorry, I misunderstood. Yes, you're right. Since clk has been allocated
with kzalloc it would be released for the failing.
Thanks for advisement. I'll fix it.

Thanks.


      reply	other threads:[~2012-08-24  8:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-27 10:31 [PATCH v4] clock: max77686: Add driver for Maxim 77686 32KHz crystal oscillator Jonghwa Lee
2012-08-24  2:07 ` Mike Turquette
2012-08-24  7:47   ` jonghwa3.lee
2012-08-24  8:12     ` jonghwa3.lee [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=5037376A.9000507@samsung.com \
    --to=jonghwa3.lee@samsung.com \
    --cc=arnd@arndb.de \
    --cc=hsweeten@visionengravers.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@linaro.org \
    --cc=myungjoo.ham@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.