From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Vadym Kochan <vadym.kochan@plvision.eu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] nvmem: core: fix possibly memleak when use nvmem_cell_info_to_nvmem_cell()
Date: Wed, 23 Sep 2020 17:25:05 +0100 [thread overview]
Message-ID: <cec8a363-0c2b-2746-d986-f239f74eaff7@linaro.org> (raw)
In-Reply-To: <20200923162314.GF16798@plvision.eu>
On 23/09/2020 17:23, Vadym Kochan wrote:
> On Wed, Sep 23, 2020 at 04:51:06PM +0100, Srinivas Kandagatla wrote:
>>
>>
>> On 23/09/2020 15:51, Vadym Kochan wrote:
>>>> - return nvmem_cell_write(&cell, buf, cell.bytes);
>>>> + rc = nvmem_cell_write(&cell, buf, cell.bytes);
>>>> + if (rc)
>>>> + kfree_const(cell->name);
>>>> +
>>>> + return rc;
>>>> }
>>>> EXPORT_SYMBOL_GPL(nvmem_device_cell_write);
>>>> ------------------------>cut<---------------------------
>>>>
>>>> --srini
>>>>
>>> But is it really needed to kstrdup(cell->name) for nvmem_device_cell_{read,write} ?
>> This boils down to if we want to use same api to parse nvmem_cell_info or
>> not!
>>
>> If we want to keep this simple, we can either explicitly add free for
>> successful caller to nvmem_cell_info_to_nvmem_cell()!
>>
>> Or
>>
>> use something like what you did, but new api needs more clarity!
>> May be renaming __nvmem_cell_info_to_nvmem_cell to
>> nvmem_cell_info_to_nvmem_cell_no_alloc would clarify that a bit!
>>
>
> Naming is most difficult thing, what about __nvmem_cell_info_to_nvmem_cell_{unsafe,nodup}() ?
> At least this is an indication to be carefully here.
nvmem_cell_info_to_nvmem_cell_nodup() should be good!
--srini
>
>> Also can you make sure that linewrapping on function names be inline with
>> existing code.
>>
>> Please send v3 with that changes!
>>
>>
>> --srini
>>> It is used only for log error in case the unaligned access did not
>>> pass the check
prev parent reply other threads:[~2020-09-23 16:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-23 13:53 Vadym Kochan
2020-09-23 14:10 ` Srinivas Kandagatla
2020-09-23 14:13 ` Vadym Kochan
2020-09-23 14:47 ` Srinivas Kandagatla
2020-09-23 14:51 ` Vadym Kochan
2020-09-23 15:51 ` Srinivas Kandagatla
2020-09-23 16:02 ` Vadym Kochan
2020-09-23 16:03 ` Srinivas Kandagatla
2020-09-23 16:23 ` Vadym Kochan
2020-09-23 16:25 ` Srinivas Kandagatla [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=cec8a363-0c2b-2746-d986-f239f74eaff7@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vadym.kochan@plvision.eu \
/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®