From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: rjw@rjwysocki.net, heiko@sntech.de, lukasz.luba@arm.com,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
Daniel Lezcano <daniel.lezcano@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH v1 3/7] powercap/dtpm: Fixup kfree for virtual node
Date: Tue, 22 Feb 2022 16:59:29 +0100 [thread overview]
Message-ID: <2d78266d-0b49-593e-79d8-00215c14fde5@linaro.org> (raw)
In-Reply-To: <CAPDyKFqo1vhhW994NsnWonTWW34qcSMU5xaBZyV76Njtr0ST4w@mail.gmail.com>
On 22/02/2022 16:55, Ulf Hansson wrote:
> On Fri, 18 Feb 2022 at 14:18, Daniel Lezcano <daniel.lezcano@linaro.org> wrote:
>>
>> On 17/02/2022 16:45, Ulf Hansson wrote:
>>
>> [ ... ]
>>
>>> Does ops->release() also resets the "dtpm" pointer to NULL? If not,
>>> it's good practice that it should, right?
>>>
>>> In that case, we would be calling "kfree(NULL);" the second time,
>>> which is perfectly fine.
>>
>> So you suggest to replace:
>>
>> if (ops->release)
>> ops->release(dtpm);
>> else
>> kfree(dtpm);
>>
>> By:
>>
>> if (ops->release) {
>> ops->release(dtpm);
>> dtpm = NULL;
>> }
>>
>
> I don't have a strong opinion how to code this.
>
> What I was trying to point out was that if ->ops->release() frees the
> memory it could/should also reset the pointer to NULL
No it can't because it is not a pointer, it is contained by the backend
specific structure.
eg.
struct dtpm_cpu {
struct dtpm dtpm;
};
the release frees a dtpm_cpu structure.
> And if that is already done, the kfree below is harmless and there
> would be nothing to "fix".
>
>> kfree(dtpm);
>>
>> ?
>
> Kind regards
> Uffe
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
next prev parent reply other threads:[~2022-02-22 15:59 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-30 21:02 [PATCH v1 1/7] powercap/dtpm: Change locking scheme Daniel Lezcano
2022-01-30 21:02 ` [PATCH v1 2/7] powercap/dtpm_cpu: Reset per_cpu variable in the release function Daniel Lezcano
2022-02-16 16:24 ` Ulf Hansson
2022-01-30 21:02 ` [PATCH v1 3/7] powercap/dtpm: Fixup kfree for virtual node Daniel Lezcano
2022-02-16 16:22 ` Ulf Hansson
2022-02-16 18:10 ` Daniel Lezcano
2022-02-17 13:17 ` Ulf Hansson
2022-02-17 13:54 ` Daniel Lezcano
2022-02-17 15:45 ` Ulf Hansson
2022-02-18 13:17 ` Daniel Lezcano
2022-02-22 15:55 ` Ulf Hansson
2022-02-22 15:59 ` Daniel Lezcano [this message]
2022-01-30 21:02 ` [PATCH v1 4/7] powercap/dtpm: Destroy hierarchy function Daniel Lezcano
2022-02-16 16:31 ` Ulf Hansson
2022-02-16 19:25 ` Daniel Lezcano
2022-02-17 13:12 ` Ulf Hansson
2022-02-17 13:17 ` Ulf Hansson
2022-01-30 21:02 ` [PATCH v1 5/7] powercap/dtpm: Move the 'root' reset place Daniel Lezcano
2022-02-17 13:19 ` Ulf Hansson
2022-01-30 21:02 ` [PATCH v1 6/7] powercap/dtpm/dtpm_cpu: Add exit function Daniel Lezcano
2022-02-17 13:20 ` Ulf Hansson
2022-01-30 21:02 ` [PATCH v1 7/7] dtpm/soc/rk3399: Add the ability to unload the module Daniel Lezcano
2022-02-17 13:21 ` Ulf Hansson
2022-02-16 16:24 ` [PATCH v1 1/7] powercap/dtpm: Change locking scheme Ulf Hansson
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=2d78266d-0b49-593e-79d8-00215c14fde5@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=daniel.lezcano@kernel.org \
--cc=heiko@sntech.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=rjw@rjwysocki.net \
--cc=ulf.hansson@linaro.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®