Skip to contentSkip to conversation

ubifs: Fix potential memory leaks while iterating entries

PATCH Markus Elfring 3 participants 5 messages Jun 1, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
Quoted 2 lines

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

Such information is useful.

Quoted 3 lines

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=77e6a8804abcc0504c904bd6e5cdf3a5cf8162#n455

Regards,
Markus

#1 lore raw
Quoted 9 lines · Markus Elfring
Quoted 2 lines

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

Such information is useful.

Quoted 3 lines

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.

Quoted 5 lines

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=77e6a8804abcc0504c904bd6e5cdf3a5cf8162#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.

Quoted 4 lines

Regards,
Markus

.

#2 lore raw
Quoted 4 lines · Zhihao Cheng
Quoted 2 lines · Markus Elfring
Quoted 2 lines

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

Quoted 8 lines
Quoted 7 lines

Such information is useful.

Quoted 3 lines

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!

Signature · 2 lines
Thanks,
//richard
#3 lore raw
In reply to Zhihao Cheng
Quoted 5 lines
Quoted 4 lines

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.

Quoted 2 lines

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?

Quoted 1 line

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/[email protected]/
https://lore.kernel.org/patchwork/patch/1250456/

Regards,
Markus

#4 lore raw
Quoted 18 lines · Markus Elfring
Quoted 6 lines
Quoted 5 lines

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.

Quoted 2 lines

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?

Quoted 1 line

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

Quoted 8 lines

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/[email protected]/
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.

Signature · 2 lines
Thanks,
//richard