Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
* Re: [PATCH] exfat: call brelse() on error path
@ 2020-06-10 12:07 Markus Elfring
  2020-06-10 17:22 ` [PATCH v2] exfat: add missing brelse() calls on error paths Dan Carpenter
  0 siblings, 1 reply; 11+ messages in thread
From: Markus Elfring @ 2020-06-10 12:07 UTC (permalink / raw)
  To: Dan Carpenter, linux-fsdevel
  Cc: kernel-janitors, linux-kernel, Namjae Jeon, Sungjong Seo,
	Pali Rohár, Tetsuhiro Kohada, Wei Yongjun

> 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/208cba7b-e535-c8e0-5ac7-f15170117a7f@web.de/
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

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

* [PATCH v2] exfat: add missing brelse() calls on error paths
  2020-06-10 12:07 [PATCH] exfat: call brelse() on error path Markus Elfring
@ 2020-06-10 17:22 ` Dan Carpenter
  2020-06-10 18:12   ` Markus Elfring
                     ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Dan Carpenter @ 2020-06-10 17:22 UTC (permalink / raw)
  To: Markus Elfring
  Cc: linux-fsdevel, kernel-janitors, linux-kernel, Namjae Jeon,
	Sungjong Seo, Pali Rohár, Tetsuhiro Kohada, Wei Yongjun

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")
Reported-by: Markus Elfring <Markus.Elfring@web.de>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: fix exfat_move_file() as well.  Also add a Fixes tag.

 fs/exfat/namei.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
index 5b0f35329d63e..edd8023865a0e 100644
--- a/fs/exfat/namei.c
+++ b/fs/exfat/namei.c
@@ -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));
-- 
2.26.2


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

* Re: [PATCH v2] exfat: add missing brelse() calls on error paths
  2020-06-10 17:22 ` [PATCH v2] exfat: add missing brelse() calls on error paths Dan Carpenter
@ 2020-06-10 18:12   ` Markus Elfring
  2020-06-10 18:45     ` Dan Carpenter
  2020-06-11  3:41   ` [PATCH v2] " Namjae Jeon
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Markus Elfring @ 2020-06-10 18:12 UTC (permalink / raw)
  To: Dan Carpenter, linux-fsdevel
  Cc: kernel-janitors, linux-kernel, Namjae Jeon, Sungjong Seo,
	Pali Rohár, Tetsuhiro Kohada, Wei Yongjun

> 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

Regards,
Markus

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

* Re: [PATCH v2] exfat: add missing brelse() calls on error paths
  2020-06-10 18:12   ` Markus Elfring
@ 2020-06-10 18:45     ` Dan Carpenter
  2020-06-10 18:56       ` Markus Elfring
  0 siblings, 1 reply; 11+ messages in thread
From: Dan Carpenter @ 2020-06-10 18:45 UTC (permalink / raw)
  To: Markus Elfring
  Cc: linux-fsdevel, kernel-janitors, linux-kernel, Namjae Jeon,
	Sungjong Seo, Pali Rohár, Tetsuhiro Kohada, Wei Yongjun

On Wed, Jun 10, 2020 at 08:12:46PM +0200, Markus Elfring wrote:
> > 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.

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

regards,
dan carpenter


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

* Re: [PATCH v2] exfat: add missing brelse() calls on error paths
  2020-06-10 18:45     ` Dan Carpenter
@ 2020-06-10 18:56       ` Markus Elfring
  2020-06-10 19:22         ` Matthew Wilcox
  0 siblings, 1 reply; 11+ messages in thread
From: Markus Elfring @ 2020-06-10 18:56 UTC (permalink / raw)
  To: Dan Carpenter, linux-fsdevel
  Cc: kernel-janitors, linux-kernel, Namjae Jeon, Sungjong Seo,
	Pali Rohár, Tetsuhiro Kohada, Wei Yongjun

>>> 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?


> 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

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

* Re: [PATCH v2] exfat: add missing brelse() calls on error paths
  2020-06-10 18:56       ` Markus Elfring
@ 2020-06-10 19:22         ` Matthew Wilcox
  2020-06-10 20:00           ` Markus Elfring
  0 siblings, 1 reply; 11+ messages in thread
From: Matthew Wilcox @ 2020-06-10 19:22 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Dan Carpenter, linux-fsdevel, kernel-janitors, linux-kernel,
	Namjae Jeon, Sungjong Seo, Pali Rohár, Tetsuhiro Kohada,
	Wei Yongjun

On Wed, Jun 10, 2020 at 08:56:26PM +0200, Markus Elfring wrote:
> >>> 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?
> 
> 
> > 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?

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

* Re: exfat: add missing brelse() calls on error paths
  2020-06-10 19:22         ` Matthew Wilcox
@ 2020-06-10 20:00           ` Markus Elfring
  0 siblings, 0 replies; 11+ messages in thread
From: Markus Elfring @ 2020-06-10 20:00 UTC (permalink / raw)
  To: Matthew Wilcox, linux-fsdevel
  Cc: kernel-janitors, linux-kernel, Namjae Jeon, Sungjong Seo,
	Pali Rohár, Tetsuhiro Kohada, Wei Yongjun, Dan Carpenter

> You're nitpicking commit messages.

I am occasionally trying to achieve corresponding improvements.


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

Would you like to follow official patch process documentation?


> 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.


> 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.


> 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?


> and yet you use it in almost every email.

You exaggerate here.


> 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

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

* RE: [PATCH v2] exfat: add missing brelse() calls on error paths
  2020-06-10 17:22 ` [PATCH v2] exfat: add missing brelse() calls on error paths Dan Carpenter
  2020-06-10 18:12   ` Markus Elfring
@ 2020-06-11  3:41   ` Namjae Jeon
  2020-06-11  8:00   ` Markus Elfring
  2020-06-11  8:40   ` Markus Elfring
  3 siblings, 0 replies; 11+ messages in thread
From: Namjae Jeon @ 2020-06-11  3:41 UTC (permalink / raw)
  To: 'Dan Carpenter'
  Cc: linux-fsdevel, kernel-janitors, linux-kernel,
	'Sungjong Seo', 'Pali Rohár',
	'Markus Elfring', 'Tetsuhiro Kohada',
	'Wei Yongjun'

> 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")
> Reported-by: Markus Elfring <Markus.Elfring@web.de>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Applied. Thanks!


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

* Re: [PATCH v2] exfat: add missing brelse() calls on error paths
  2020-06-10 17:22 ` [PATCH v2] exfat: add missing brelse() calls on error paths Dan Carpenter
  2020-06-10 18:12   ` Markus Elfring
  2020-06-11  3:41   ` [PATCH v2] " Namjae Jeon
@ 2020-06-11  8:00   ` Markus Elfring
  2020-06-11  8:40   ` Markus Elfring
  3 siblings, 0 replies; 11+ messages in thread
From: Markus Elfring @ 2020-06-11  8:00 UTC (permalink / raw)
  To: Dan Carpenter, Namjae Jeon, Sungjong Seo, linux-fsdevel
  Cc: kernel-janitors, linux-kernel, Pali Rohár, Tetsuhiro Kohada,
	Wei Yongjun

…
> +++ b/fs/exfat/namei.c
> @@ -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

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

* Re: [PATCH v2] exfat: add missing brelse() calls on error paths
  2020-06-10 17:22 ` [PATCH v2] exfat: add missing brelse() calls on error paths Dan Carpenter
                     ` (2 preceding siblings ...)
  2020-06-11  8:00   ` Markus Elfring
@ 2020-06-11  8:40   ` Markus Elfring
  3 siblings, 0 replies; 11+ messages in thread
From: Markus Elfring @ 2020-06-11  8:40 UTC (permalink / raw)
  To: Dan Carpenter, Namjae Jeon, Sungjong Seo, linux-fsdevel
  Cc: kernel-janitors, linux-kernel, Pali Rohár, Tetsuhiro Kohada,
	Wei Yongjun

…
> +++ b/fs/exfat/namei.c
> @@ -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

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

* [PATCH] exfat: call brelse() on error path
  2020-06-10  9:27 exfat: Improving exception handling in two functions Markus Elfring
@ 2020-06-10  9:59 ` Dan Carpenter
  0 siblings, 0 replies; 11+ messages in thread
From: Dan Carpenter @ 2020-06-10  9:59 UTC (permalink / raw)
  To: Namjae Jeon, linux-fsdevel, Sungjong Seo
  Cc: kernel-janitors, linux-kernel, Pali Rohár, Tetsuhiro Kohada,
	Wei Yongjun

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

Reported-by: Markus Elfring <Markus.Elfring@web.de>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 fs/exfat/namei.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
index 5b0f35329d63e..fda92c824ff11 100644
--- a/fs/exfat/namei.c
+++ b/fs/exfat/namei.c
@@ -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);
-- 
2.26.2


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

end of thread, other threads:[~2020-06-11  8:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-10 12:07 [PATCH] exfat: call brelse() on error path Markus Elfring
2020-06-10 17:22 ` [PATCH v2] exfat: add missing brelse() calls on error paths Dan Carpenter
2020-06-10 18:12   ` Markus Elfring
2020-06-10 18:45     ` Dan Carpenter
2020-06-10 18:56       ` Markus Elfring
2020-06-10 19:22         ` Matthew Wilcox
2020-06-10 20:00           ` Markus Elfring
2020-06-11  3:41   ` [PATCH v2] " Namjae Jeon
2020-06-11  8:00   ` Markus Elfring
2020-06-11  8:40   ` Markus Elfring
  -- strict thread matches above, loose matches on Subject: below --
2020-06-10  9:27 exfat: Improving exception handling in two functions Markus Elfring
2020-06-10  9:59 ` [PATCH] exfat: call brelse() on error path Dan Carpenter

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).