All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Zapolskiy <vz@mleia.com>
To: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Cc: Kukjin Kim <kgene@kernel.org>,
	linux-samsung-soc@vger.kernel.org,
	Russell King <linux@arm.linux.org.uk>,
	linux-arm-kernel@lists.infradead.org,
	Marek Szyprowski <m.szyprowski@samsung.com>
Subject: Re: [PATCH] ARM: EXYNOS: pd: fix resource deallocation on error path
Date: Thu, 30 Jul 2015 03:06:30 +0300	[thread overview]
Message-ID: <55B96A86.8000502@mleia.com> (raw)
In-Reply-To: <CAJKOXPeWgXR0SuRzZyXHSiewZDuuJXXFmjyWasXDFxDAQUzyqA@mail.gmail.com>

On 30.07.2015 02:37, Krzysztof Kozlowski wrote:
> 2015-07-30 5:15 GMT+09:00 Vladimir Zapolskiy <vz@mleia.com>:
>> The change fixes a bug introduced by 2be2a3ff42a5, memory allocated
>> by kstrdup_const() must be always deallocated with kfree_const(),
>> otherwise there is a risk of kfree'ing ro memory.
> 
> This looks good. Can you provide also Cc-stable and fixes tags?

Since the change fixes two independent issues I decided not to add a
particular commit to Fixes tag. I can split the commit of course, but I
feel reluctant to send a series in this particular case.

Let me know your decision with respect to my comments.

>>
>> Also remove unneeded of_node_put(), if for_each_compatible_node() body
>> execution is not terminated, this prevents from double kfree() in
>> OF_DYNAMIC build.
> 
> Each iteration of for_each_compatible_node() has a check:
> (dn = of_find_compatible_node(dn, type, compatible))
> this increases the references to 'np'. 

Correct.

> If loop continues then previous 'np' is not of_node_put().

This I don't understand. The previous 'np' is of_node_put() on next
iteration of the loop, i.e. if and only if loop continues. Please elaborate.

--
With best wishes,
Vladimir

> 
>>
>> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
>> ---
>>  arch/arm/mach-exynos/pm_domains.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/arch/arm/mach-exynos/pm_domains.c b/arch/arm/mach-exynos/pm_domains.c
>> index 6001f1c..4a87e86 100644
>> --- a/arch/arm/mach-exynos/pm_domains.c
>> +++ b/arch/arm/mach-exynos/pm_domains.c
>> @@ -146,9 +146,8 @@ static __init int exynos4_pm_init_power_domain(void)
>>                 pd->base = of_iomap(np, 0);
>>                 if (!pd->base) {
>>                         pr_warn("%s: failed to map memory\n", __func__);
>> -                       kfree(pd->pd.name);
>> +                       kfree_const(pd->pd.name);
>>                         kfree(pd);
>> -                       of_node_put(np);
>>                         continue;
>>                 }
>>
>> --
>> 2.1.4
>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: vz@mleia.com (Vladimir Zapolskiy)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: EXYNOS: pd: fix resource deallocation on error path
Date: Thu, 30 Jul 2015 03:06:30 +0300	[thread overview]
Message-ID: <55B96A86.8000502@mleia.com> (raw)
In-Reply-To: <CAJKOXPeWgXR0SuRzZyXHSiewZDuuJXXFmjyWasXDFxDAQUzyqA@mail.gmail.com>

On 30.07.2015 02:37, Krzysztof Kozlowski wrote:
> 2015-07-30 5:15 GMT+09:00 Vladimir Zapolskiy <vz@mleia.com>:
>> The change fixes a bug introduced by 2be2a3ff42a5, memory allocated
>> by kstrdup_const() must be always deallocated with kfree_const(),
>> otherwise there is a risk of kfree'ing ro memory.
> 
> This looks good. Can you provide also Cc-stable and fixes tags?

Since the change fixes two independent issues I decided not to add a
particular commit to Fixes tag. I can split the commit of course, but I
feel reluctant to send a series in this particular case.

Let me know your decision with respect to my comments.

>>
>> Also remove unneeded of_node_put(), if for_each_compatible_node() body
>> execution is not terminated, this prevents from double kfree() in
>> OF_DYNAMIC build.
> 
> Each iteration of for_each_compatible_node() has a check:
> (dn = of_find_compatible_node(dn, type, compatible))
> this increases the references to 'np'. 

Correct.

> If loop continues then previous 'np' is not of_node_put().

This I don't understand. The previous 'np' is of_node_put() on next
iteration of the loop, i.e. if and only if loop continues. Please elaborate.

--
With best wishes,
Vladimir

> 
>>
>> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
>> ---
>>  arch/arm/mach-exynos/pm_domains.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/arch/arm/mach-exynos/pm_domains.c b/arch/arm/mach-exynos/pm_domains.c
>> index 6001f1c..4a87e86 100644
>> --- a/arch/arm/mach-exynos/pm_domains.c
>> +++ b/arch/arm/mach-exynos/pm_domains.c
>> @@ -146,9 +146,8 @@ static __init int exynos4_pm_init_power_domain(void)
>>                 pd->base = of_iomap(np, 0);
>>                 if (!pd->base) {
>>                         pr_warn("%s: failed to map memory\n", __func__);
>> -                       kfree(pd->pd.name);
>> +                       kfree_const(pd->pd.name);
>>                         kfree(pd);
>> -                       of_node_put(np);
>>                         continue;
>>                 }
>>
>> --
>> 2.1.4
>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2015-07-30  0:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-29 20:15 [PATCH] ARM: EXYNOS: pd: fix resource deallocation on error path Vladimir Zapolskiy
2015-07-29 20:15 ` Vladimir Zapolskiy
2015-07-29 23:37 ` Krzysztof Kozlowski
2015-07-29 23:37   ` Krzysztof Kozlowski
2015-07-30  0:06   ` Vladimir Zapolskiy [this message]
2015-07-30  0:06     ` Vladimir Zapolskiy
2015-07-30  0:15     ` Krzysztof Kozlowski
2015-07-30  0:15       ` Krzysztof Kozlowski
2015-07-30  0:35       ` Vladimir Zapolskiy
2015-07-30  0:35         ` Vladimir Zapolskiy
2015-07-30  0:55         ` Krzysztof Kozlowski
2015-07-30  0:55           ` Krzysztof Kozlowski

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=55B96A86.8000502@mleia.com \
    --to=vz@mleia.com \
    --cc=k.kozlowski@samsung.com \
    --cc=kgene@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=m.szyprowski@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.