Skip to contentSkip to conversation

exfat: call brelse() on error path

PATCH Applied Markus Elfring 4 participants 10 messages Jun 10, 2020 – Jun 11, 2020

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

If the second exfat_get_dentry() call fails then we need to release "old_bh" before returning.

Thanks you picked a bit of information up from my source code analysis for a possible adjustment of the function “exfat_rename_file”.

exfat: Improving exception handling in two functions
https://lore.kernel.org/linux-fsdevel/[email protected]/
https://lkml.org/lkml/2020/6/10/272

Would you like to adjust the implementation of the function “exfat_move_file” in a similar way in a subsequent patch variant?

Regards,
Markus

#1 lore raw

PATCH v2 1/1 exfat: add missing brelse() calls on error paths

If the second exfat_get_dentry() call fails then we need to release "old_bh" before returning. There is a similar bug in exfat_move_file().

Fixes 5f2aa075070c ("exfat: add inode operations")

---
v2: fix exfat_move_file() as well. Also add a Fixes tag.

 fs/exfat/namei.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
fs/exfat/namei.c +10 -2
index 5b0f35329d63e..edd8023865a0e 100644
@@ -1077,10 +1077,14 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir,
 
 		epold = exfat_get_dentry(sb, p_dir, oldentry + 1, &old_bh,
 			&sector_old);
+		if (!epold)
+			return -EIO;
 		epnew = exfat_get_dentry(sb, p_dir, newentry + 1, &new_bh,
 			&sector_new);
-		if (!epold || !epnew)
+		if (!epnew) {
+			brelse(old_bh);
 			return -EIO;
+		}
 
 		memcpy(epnew, epold, DENTRY_SIZE);
 		exfat_update_bh(sb, new_bh, sync);
@@ -1161,10 +1165,14 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir,
 
 	epmov = exfat_get_dentry(sb, p_olddir, oldentry + 1, &mov_bh,
 		&sector_mov);
+	if (!epmov)
+		return -EIO;
 	epnew = exfat_get_dentry(sb, p_newdir, newentry + 1, &new_bh,
 		&sector_new);
-	if (!epmov || !epnew)
+	if (!epnew) {
+		brelse(mov_bh);
 		return -EIO;
+	}
 
 	memcpy(epnew, epmov, DENTRY_SIZE);
 	exfat_update_bh(sb, new_bh, IS_DIRSYNC(inode));
Signature · 1 line
2.26.2
#2 lore raw

Re: [PATCH v2] exfat: add missing brelse() calls on error paths

Quoted 2 lines

If the second exfat_get_dentry() call fails then we need to release "old_bh" before returning. There is a similar bug in exfat_move_file().

Would you like to convert any information from this change description into an imperative wording?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id[14671be58d0084e7e2d1cc9c2c36a94467f6e0#n151

Regards,
Markus

#3 lore raw

Re: [PATCH v2] exfat: add missing brelse() calls on error paths

Quoted 6 lines · Markus Elfring
Quoted 2 lines

If the second exfat_get_dentry() call fails then we need to release "old_bh" before returning. There is a similar bug in exfat_move_file().

Would you like to convert any information from this change description into an imperative wording?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id[14671be58d0084e7e2d1cc9c2c36a94467f6e0#n151

I really feel like imperative doesn't add anything. I understand that some people feel really strongly about it, but I don't know why. It doesn't make commit messages more understandable.

The important thing is that the problem is clear, the fix is clear and the runtime impact is clear.

regards,
dan carpenter

#4 lore raw

Re: [PATCH v2] exfat: add missing brelse() calls on error paths

Quoted 10 lines
Quoted 6 lines
Quoted 2 lines

If the second exfat_get_dentry() call fails then we need to release "old_bh" before returning. There is a similar bug in exfat_move_file().

Would you like to convert any information from this change description into an imperative wording?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=5b14671be58d0084e7e2d1cc9c2c36a94467f6e0#n151

I really feel like imperative doesn't add anything. I understand that some people feel really strongly about it, but I don't know why. It doesn't make commit messages more understandable.

Do you insist to deviate from the given guideline?

Quoted 2 lines

The important thing is that the problem is clear, the fix is clear and the runtime impact is clear.

I have got further ideas to improve also this commit message. I am curious if other contributors would like to add another bit of patch review.

Regards,
Markus

#5 lore raw

Re: [PATCH v2] exfat: add missing brelse() calls on error paths

Quoted 14 lines · Markus Elfring
Quoted 10 lines
Quoted 6 lines
Quoted 2 lines

If the second exfat_get_dentry() call fails then we need to release "old_bh" before returning. There is a similar bug in exfat_move_file().

Would you like to convert any information from this change description into an imperative wording?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id[14671be58d0084e7e2d1cc9c2c36a94467f6e0#n151

I really feel like imperative doesn't add anything. I understand that some people feel really strongly about it, but I don't know why. It doesn't make commit messages more understandable.

Do you insist to deviate from the given guideline?

Quoted 6 lines
Quoted 2 lines

The important thing is that the problem is clear, the fix is clear and the runtime impact is clear.

I have got further ideas to improve also this commit message. I am curious if other contributors would like to add another bit of patch review.

You're nitpicking commit messages. This is exactly the kind of thing which drives people away. Dan's commit message is fine.

It's actually hilarious because your emails are so unclear that I can't understand them. I have no idea what "collateral evolution" means and yet you use it in almost every email. Why can't you use the same terminology the rest of us use?

#6 lore raw

Re: exfat: add missing brelse() calls on error paths

Quoted 1 line

You're nitpicking commit messages.

I am occasionally trying to achieve corresponding improvements.

Quoted 1 line

This is exactly the kind of thing which drives people away.

Would you like to follow official patch process documentation?

Quoted 1 line

Dan's commit message is fine.

I have got the impression that he indicates another deviation from a well-known requirement. I am curious under which circumstances such a patch review concern will be taken into account finally.

Quoted 2 lines

It's actually hilarious because your emails are so unclear that I can't understand them.

I find such feedback surprising and interesting.
I hope that we can reduce understanding difficulties together.

Quoted 1 line

I have no idea what "collateral evolution" means

This term expresses the situation that a single change can trigger further changes.

Examples for programmers:
A)
* You add an argument to an used function.
* How many function calls will need related adjustments?

B)
* Some function calls can fail.
* How do you think about to complete error detection and the corresponding exception handling?

Quoted 1 line

and yet you use it in almost every email.

You exaggerate here.

Quoted 1 line

Why can't you use the same terminology the rest of us use?

I got also used to some wording approaches.
Which terminology variation do you prefer?

Regards,
Markus

#8 lore raw

Re: [PATCH v2] exfat: add missing brelse() calls on error paths

In reply to Dan Carpenter

…

fs/exfat/namei.c static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, · line 1081

Quoted 7 lines

+++ b/fs/exfat/namei.c

fs/exfat/namei.c +2 -0
@@ -1077,10 +1077,14 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir,
 
 		epold = exfat_get_dentry(sb, p_dir, oldentry + 1, &old_bh,
 			&sector_old);
+		if (!epold)
+			return -EIO;

…

Can it become helpful to annotate such null pointer checks for branch prediction? Would you like to indicate a likelihood in any way?

Regards,
Markus

#9 lore raw

Re: [PATCH v2] exfat: add missing brelse() calls on error paths

In reply to Dan Carpenter

…

fs/exfat/namei.c static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, · line 1081

Quoted 7 lines

+++ b/fs/exfat/namei.c

fs/exfat/namei.c +2 -0
@@ -1077,10 +1077,14 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir,
 
 		epold = exfat_get_dentry(sb, p_dir, oldentry + 1, &old_bh,
 			&sector_old);
+		if (!epold)
+			return -EIO;

…

Will there be a need to reconsider the indentation for function call parameters in such source files?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=b29482fde649c72441d5478a4ea2c52c56d97a5e#n93

Regards,
Markus