* [PATCH] btrfs: fix error value in btrfs_get_extent
@ 2020-08-03 9:35 Pavel Machek
2020-08-03 9:39 ` Nikolay Borisov
2020-08-11 10:25 ` David Sterba
0 siblings, 2 replies; 5+ messages in thread
From: Pavel Machek @ 2020-08-03 9:35 UTC (permalink / raw)
To: clm, jbacik, dsterba, sashal, wqu, nborisov, linux-btrfs,
linux-kernel, jungyeon, stable
[-- Attachment #1: Type: text/plain, Size: 940 bytes --]
btrfs_get_extent() sets variable ret, but out: error path expect error
to be in variable err. Fix that.
Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
---
Notice that patch introducing this problem is on its way to 4.19.137-stable.
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 7befb7c12bd3..4aaa01540f89 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7012,7 +7012,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
found_type == BTRFS_FILE_EXTENT_PREALLOC) {
/* Only regular file could have regular/prealloc extent */
if (!S_ISREG(inode->vfs_inode.i_mode)) {
- ret = -EUCLEAN;
+ err = -EUCLEAN;
btrfs_crit(fs_info,
"regular/prealloc extent found for non-regular inode %llu",
btrfs_ino(inode));
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: fix error value in btrfs_get_extent
2020-08-03 9:35 [PATCH] btrfs: fix error value in btrfs_get_extent Pavel Machek
@ 2020-08-03 9:39 ` Nikolay Borisov
2020-08-03 9:50 ` Nikolay Borisov
2020-08-11 10:25 ` David Sterba
1 sibling, 1 reply; 5+ messages in thread
From: Nikolay Borisov @ 2020-08-03 9:39 UTC (permalink / raw)
To: Pavel Machek, clm, jbacik, dsterba, sashal, wqu, linux-btrfs,
linux-kernel, jungyeon, stable
On 3.08.20 г. 12:35 ч., Pavel Machek wrote:
> btrfs_get_extent() sets variable ret, but out: error path expect error
> to be in variable err. Fix that.
>
> Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
Good catch, this also needs:
Fixes: 6bf9e4bd6a27 ("btrfs: inode: Verify inode mode to avoid NULL
pointer dereference")
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
>
> ---
>
> Notice that patch introducing this problem is on its way to 4.19.137-stable.
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 7befb7c12bd3..4aaa01540f89 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -7012,7 +7012,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
> found_type == BTRFS_FILE_EXTENT_PREALLOC) {
> /* Only regular file could have regular/prealloc extent */
> if (!S_ISREG(inode->vfs_inode.i_mode)) {
> - ret = -EUCLEAN;
> + err = -EUCLEAN;
> btrfs_crit(fs_info,
> "regular/prealloc extent found for non-regular inode %llu",
> btrfs_ino(inode));
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: fix error value in btrfs_get_extent
2020-08-03 9:39 ` Nikolay Borisov
@ 2020-08-03 9:50 ` Nikolay Borisov
2020-08-11 10:28 ` David Sterba
0 siblings, 1 reply; 5+ messages in thread
From: Nikolay Borisov @ 2020-08-03 9:50 UTC (permalink / raw)
To: Pavel Machek, clm, jbacik, dsterba, sashal, wqu, linux-btrfs,
linux-kernel, jungyeon, stable
On 3.08.20 г. 12:39 ч., Nikolay Borisov wrote:
>
>
> On 3.08.20 г. 12:35 ч., Pavel Machek wrote:
>> btrfs_get_extent() sets variable ret, but out: error path expect error
>> to be in variable err. Fix that.
>>
>> Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
>
> Good catch, this also needs:
>
> Fixes: 6bf9e4bd6a27 ("btrfs: inode: Verify inode mode to avoid NULL
> pointer dereference")
>
> Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Actually the reason this error got introduced in the first place and I
missed it during the review is that the function is doing something
rather counter-intuitive - it's using 'err' variable as a synonym for
'ret'. A better approach would be to simply remove 'err' from that
function. I'm now authoring such a patch, nevertheless the issue still
stands.
>
>
>>
>> ---
>>
>> Notice that patch introducing this problem is on its way to 4.19.137-stable.
>>
>> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
>> index 7befb7c12bd3..4aaa01540f89 100644
>> --- a/fs/btrfs/inode.c
>> +++ b/fs/btrfs/inode.c
>> @@ -7012,7 +7012,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
>> found_type == BTRFS_FILE_EXTENT_PREALLOC) {
>> /* Only regular file could have regular/prealloc extent */
>> if (!S_ISREG(inode->vfs_inode.i_mode)) {
>> - ret = -EUCLEAN;
>> + err = -EUCLEAN;
>> btrfs_crit(fs_info,
>> "regular/prealloc extent found for non-regular inode %llu",
>> btrfs_ino(inode));
>>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: fix error value in btrfs_get_extent
2020-08-03 9:35 [PATCH] btrfs: fix error value in btrfs_get_extent Pavel Machek
2020-08-03 9:39 ` Nikolay Borisov
@ 2020-08-11 10:25 ` David Sterba
1 sibling, 0 replies; 5+ messages in thread
From: David Sterba @ 2020-08-11 10:25 UTC (permalink / raw)
To: Pavel Machek
Cc: clm, jbacik, dsterba, sashal, wqu, nborisov, linux-btrfs,
linux-kernel, jungyeon, stable
On Mon, Aug 03, 2020 at 11:35:06AM +0200, Pavel Machek wrote:
> btrfs_get_extent() sets variable ret, but out: error path expect error
> to be in variable err. Fix that.
>
> Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
Thanks, patch queued for 5.9.
>
> ---
>
> Notice that patch introducing this problem is on its way to 4.19.137-stable.
Yeah, I'll let stable team know once this patch gets merged that the
relevant patches can be picked.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: fix error value in btrfs_get_extent
2020-08-03 9:50 ` Nikolay Borisov
@ 2020-08-11 10:28 ` David Sterba
0 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2020-08-11 10:28 UTC (permalink / raw)
To: Nikolay Borisov
Cc: Pavel Machek, clm, jbacik, dsterba, sashal, wqu, linux-btrfs,
linux-kernel, jungyeon, stable
On Mon, Aug 03, 2020 at 12:50:31PM +0300, Nikolay Borisov wrote:
> On 3.08.20 г. 12:39 ч., Nikolay Borisov wrote:
> > On 3.08.20 г. 12:35 ч., Pavel Machek wrote:
> >> btrfs_get_extent() sets variable ret, but out: error path expect error
> >> to be in variable err. Fix that.
> >>
> >> Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
> >
> > Good catch, this also needs:
> >
> > Fixes: 6bf9e4bd6a27 ("btrfs: inode: Verify inode mode to avoid NULL
> > pointer dereference")
> >
> > Reviewed-by: Nikolay Borisov <nborisov@suse.com>
>
> Actually the reason this error got introduced in the first place and I
> missed it during the review is that the function is doing something
> rather counter-intuitive - it's using 'err' variable as a synonym for
> 'ret'. A better approach would be to simply remove 'err' from that
> function. I'm now authoring such a patch, nevertheless the issue still
> stands.
The expected pattern is to use 'ret' for function return value and add
other temporary variables instead of the err/ret switching, which can be
found in the oldish code still. So the cleanup is going to do the right
thing, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-08-11 10:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-03 9:35 [PATCH] btrfs: fix error value in btrfs_get_extent Pavel Machek
2020-08-03 9:39 ` Nikolay Borisov
2020-08-03 9:50 ` Nikolay Borisov
2020-08-11 10:28 ` David Sterba
2020-08-11 10:25 ` David Sterba
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).