linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 1/2] ubifs: Fix potential memory leaks while iterating entries
@ 2020-06-01 12:00 Markus Elfring
  2020-06-01 13:45 ` Zhihao Cheng
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2020-06-01 12:00 UTC (permalink / raw)
  To: Zhihao Cheng, linux-mtd
  Cc: linux-kernel, kernel-janitors, Richard Weinberger, Yi Zhang

> Fix some potential memory leaks in error handling branches while
> iterating xattr entries.

Such information is useful.


> For example, function ubifs_tnc_remove_ino()
> forgets to free pxent if it exists. Similar problems also exist in
> ubifs_purge_xattrs(), ubifs_add_orphan() and ubifs_jnl_write_inode().

Can an other wording variant be a bit nicer?


I suggest to avoid the specification of duplicate function calls
(also for the desired exception handling).
Will it be helpful to add a few jump targets?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=3d77e6a8804abcc0504c904bd6e5cdf3a5cf8162#n455

Regards,
Markus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] ubifs: Fix potential memory leaks while iterating entries
  2020-06-01 12:00 [PATCH 1/2] ubifs: Fix potential memory leaks while iterating entries Markus Elfring
@ 2020-06-01 13:45 ` Zhihao Cheng
  2020-06-01 13:55   ` Richard Weinberger
  2020-06-01 14:00   ` [1/2] " Markus Elfring
  0 siblings, 2 replies; 5+ messages in thread
From: Zhihao Cheng @ 2020-06-01 13:45 UTC (permalink / raw)
  To: Markus Elfring, linux-mtd
  Cc: linux-kernel, kernel-janitors, Richard Weinberger, Yi Zhang

在 2020/6/1 20:00, Markus Elfring 写道:
>> Fix some potential memory leaks in error handling branches while
>> iterating xattr entries.
> Such information is useful.
>
>
>> For example, function ubifs_tnc_remove_ino()
>> forgets to free pxent if it exists. Similar problems also exist in
>> ubifs_purge_xattrs(), ubifs_add_orphan() and ubifs_jnl_write_inode().
> Can an other wording variant be a bit nicer?
Thanks for reminding, I will improve this description.
>
> I suggest to avoid the specification of duplicate function calls
> (also for the desired exception handling).
> Will it be helpful to add a few jump targets?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=3d77e6a8804abcc0504c904bd6e5cdf3a5cf8162#n455
I've thought about using "goto err_tag_2" in kill_xattrs code block to 
release prev xent, but later it needs to jump to 'out_release tag‘ for 
releasing previously requested memory, which can clutter the code. It 
seems that two consecutive 'goto tags' will make the code less readable.
> Regards,
> Markus
>
> .




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] ubifs: Fix potential memory leaks while iterating entries
  2020-06-01 13:45 ` Zhihao Cheng
@ 2020-06-01 13:55   ` Richard Weinberger
  2020-06-01 14:00   ` [1/2] " Markus Elfring
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Weinberger @ 2020-06-01 13:55 UTC (permalink / raw)
  To: Zhihao Cheng
  Cc: Markus Elfring, linux-mtd, Richard Weinberger, kernel-janitors,
	LKML, Yi Zhang

On Mon, Jun 1, 2020 at 3:46 PM Zhihao Cheng <chengzhihao1@huawei.com> wrote:
>
> 在 2020/6/1 20:00, Markus Elfring 写道:
> >> Fix some potential memory leaks in error handling branches while
> >> iterating xattr entries.
> > Such information is useful.
> >
> >
> >> For example, function ubifs_tnc_remove_ino()
> >> forgets to free pxent if it exists. Similar problems also exist in
> >> ubifs_purge_xattrs(), ubifs_add_orphan() and ubifs_jnl_write_inode().
> > Can an other wording variant be a bit nicer?
> Thanks for reminding, I will improve this description.

The description is fine. No need to resend. Patch will be queued after
the merge window.
Thanks for fixing these issues!

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [1/2] ubifs: Fix potential memory leaks while iterating entries
  2020-06-01 13:45 ` Zhihao Cheng
  2020-06-01 13:55   ` Richard Weinberger
@ 2020-06-01 14:00   ` Markus Elfring
  2020-06-01 14:09     ` Richard Weinberger
  1 sibling, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2020-06-01 14:00 UTC (permalink / raw)
  To: Zhihao Cheng, linux-mtd
  Cc: linux-kernel, kernel-janitors, Richard Weinberger, Yi Zhang

>> I suggest to avoid the specification of duplicate function calls
>> (also for the desired exception handling).
>> Will it be helpful to add a few jump targets?
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=3d77e6a8804abcc0504c904bd6e5cdf3a5cf8162#n455
> I've thought about using "goto err_tag_2" in kill_xattrs code block to release prev xent,

I propose to choose better labels.


> but later it needs to jump to 'out_release tag‘ for releasing previously requested memory,
> which can clutter the code.

Would you like to reconsider this view?


> It seems that two consecutive 'goto tags' will make the code less readable.

How do you think about to try another software adjustment out in such a design direction?


Can it make sense to combine changes together with the update step
“ubifs: dent: Fix some potential memory leaks while iterating entries”
into a single patch?
https://lore.kernel.org/linux-mtd/20200601091037.3794172-2-chengzhihao1@huawei.com/
https://lore.kernel.org/patchwork/patch/1250456/

Regards,
Markus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [1/2] ubifs: Fix potential memory leaks while iterating entries
  2020-06-01 14:00   ` [1/2] " Markus Elfring
@ 2020-06-01 14:09     ` Richard Weinberger
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Weinberger @ 2020-06-01 14:09 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Zhihao Cheng, linux-mtd, Richard Weinberger, kernel-janitors,
	LKML, Yi Zhang

On Mon, Jun 1, 2020 at 4:00 PM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> >> I suggest to avoid the specification of duplicate function calls
> >> (also for the desired exception handling).
> >> Will it be helpful to add a few jump targets?
> >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=3d77e6a8804abcc0504c904bd6e5cdf3a5cf8162#n455
> > I've thought about using "goto err_tag_2" in kill_xattrs code block to release prev xent,
>
> I propose to choose better labels.
>
>
> > but later it needs to jump to 'out_release tag‘ for releasing previously requested memory,
> > which can clutter the code.
>
> Would you like to reconsider this view?
>
>
> > It seems that two consecutive 'goto tags' will make the code less readable.
>
> How do you think about to try another software adjustment out in such a design direction?
>
>
> Can it make sense to combine changes together with the update step
> “ubifs: dent: Fix some potential memory leaks while iterating entries”
> into a single patch?
> https://lore.kernel.org/linux-mtd/20200601091037.3794172-2-chengzhihao1@huawei.com/
> https://lore.kernel.org/patchwork/patch/1250456/

No. Please stop this kind of bikeshedding.
Zhihao, feel free to ignore all "advice" given by Markus Elfring.

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-01 14:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-01 12:00 [PATCH 1/2] ubifs: Fix potential memory leaks while iterating entries Markus Elfring
2020-06-01 13:45 ` Zhihao Cheng
2020-06-01 13:55   ` Richard Weinberger
2020-06-01 14:00   ` [1/2] " Markus Elfring
2020-06-01 14:09     ` Richard Weinberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).