public inbox for linux-samsung-soc@vger.kernel.org
 help / color / mirror / Atom feed
From: Sylwester Nawrocki <s.nawrocki@samsung.com>
To: "Lothar Waßmann" <LW@KARO-electronics.de>
Cc: sachin.kamat@linaro.org, linux-samsung-soc@vger.kernel.org,
	mturquette@linaro.org, tomasz.figa@gmail.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] clk: Correct handling of NULL clk in __clk_{get, put}
Date: Tue, 07 Jan 2014 14:14:54 +0100	[thread overview]
Message-ID: <52CBFDCE.7060206@samsung.com> (raw)
In-Reply-To: <20140107140019.7220eed6@ipc1.ka-ro>

Hi,

On 07/01/14 14:00, Lothar Waßmann wrote:
> Sylwester Nawrocki wrote:
>> Ensure clk->kref is dereferenced only when clk is not NULL.
>>
>> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
>> ---
>> Hi Sachin,
>>
>> please try if this patch fixes the exyno5420 boot crash.
>>
>> Thanks,
>> Sylwester
>>
>>  drivers/clk/clk.c |   13 +++++++------
>>  1 file changed, 7 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
>> index e3e0327..a1fe86f 100644
>> --- a/drivers/clk/clk.c
>> +++ b/drivers/clk/clk.c
>> @@ -2179,24 +2179,25 @@ EXPORT_SYMBOL_GPL(devm_clk_unregister);
>>   */
>>  int __clk_get(struct clk *clk)
>>  {
>> -	if (clk && !try_module_get(clk->owner))
>> -		return 0;
>> +	if (clk) {
>> +		if (!try_module_get(clk->owner))
>> +			return 0;
>>
> This change is unnecessary! The part after the && is only evaluated
> when clk is not NULL.

It is, but to ensure there is no NULL clk passed at the kref_get(&clk->ref)
line everything got moved under a common "if (clk) { }".

The code will look like this:

-----------
	if (clk) {
		if (!try_module_get(clk->owner))
			return 0;

		kref_get(&clk->ref);
	}
------------

If preferred I could make it:

------------
if (clk && !try_module_get(clk->owner))
	return 0;

if (clk)
	kref_get(&clk->ref);
------------

--
Regards,
Sylwester

  reply	other threads:[~2014-01-07 13:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-07 12:03 [PATCH] clk: Correct handling of NULL clk in __clk_{get, put} Sylwester Nawrocki
2014-01-07 13:00 ` Lothar Waßmann
2014-01-07 13:14   ` Sylwester Nawrocki [this message]
2014-01-08  4:44 ` Sachin Kamat
2014-01-10 10:04   ` Sylwester Nawrocki
2014-01-30  4:50     ` Sachin Kamat
2014-02-10 15:02       ` Sylwester Nawrocki
2014-02-24 12:59         ` Tomasz Figa
2014-02-25  6:16 ` Mike Turquette
2014-02-25 17:34   ` Tomasz Figa

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=52CBFDCE.7060206@samsung.com \
    --to=s.nawrocki@samsung.com \
    --cc=LW@KARO-electronics.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=mturquette@linaro.org \
    --cc=sachin.kamat@linaro.org \
    --cc=tomasz.figa@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox