Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1230446 > unrolled thread

[PATCH 0/2] btrfs: Fix returned errno codes

Started byLuis de Bethencourt <luisbg@osg.samsung.com>
First post2015-09-22 18:30 +0200
Last post2015-09-23 11:00 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/2] btrfs: Fix returned errno codes Luis de Bethencourt <luisbg@osg.samsung.com> - 2015-09-22 18:30 +0200
    [PATCH 1/2] btrfs: check-integrity: Fix returned errno codes Luis de Bethencourt <luisbg@osg.samsung.com> - 2015-09-22 18:40 +0200
      Re: [PATCH 1/2] btrfs: check-integrity: Fix returned errno codes David Sterba <dsterba@suse.cz> - 2015-09-23 10:50 +0200
    Re: [PATCH 0/2] btrfs: Fix returned errno codes David Sterba <dsterba@suse.cz> - 2015-09-23 11:00 +0200

#1230446 — [PATCH 0/2] btrfs: Fix returned errno codes

FromLuis de Bethencourt <luisbg@osg.samsung.com>
Date2015-09-22 18:30 +0200
Subject[PATCH 0/2] btrfs: Fix returned errno codes
Message-ID<qbyC5-2cv-19@gated-at.bofh.it>
From: Luis de Bethencourt <luis@debethencourt.com>

Hi,

These two patches fix instances where -1 is used to specify a buffer
allocation fail, instead of using -ENOMEM.

I could merge the two patches into one if that's more appropriate.

Thanks,
Luis

Luis de Bethencourt (2):
  btrfs: check-integrity: Fix returned errno codes
  btrfs: reada: Fix returned errno code

 fs/btrfs/check-integrity.c | 4 ++--
 fs/btrfs/reada.c           | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

-- 
2.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1230454 — [PATCH 1/2] btrfs: check-integrity: Fix returned errno codes

FromLuis de Bethencourt <luisbg@osg.samsung.com>
Date2015-09-22 18:40 +0200
Subject[PATCH 1/2] btrfs: check-integrity: Fix returned errno codes
Message-ID<qbyLN-2nO-43@gated-at.bofh.it>
In reply to#1230446
check-integrity is using -1 instead of the -ENOMEM defined macro to
specify that a buffer allocation failed. Since the error number is
propagated, the caller will get a -EPERM which is the wrong error
condition.

Also, the smatch tool complains with the following warnings:
btrfsic_process_superblock() warn: returning -1 instead of -ENOMEM is sloppy
btrfsic_read_block() warn: returning -1 instead of -ENOMEM is sloppy

Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
---
 fs/btrfs/check-integrity.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index ce7dec8..a6257e1 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -667,7 +667,7 @@ static int btrfsic_process_superblock(struct btrfsic_state *state,
 	selected_super = kzalloc(sizeof(*selected_super), GFP_NOFS);
 	if (NULL == selected_super) {
 		printk(KERN_INFO "btrfsic: error, kmalloc failed!\n");
-		return -1;
+		return -ENOMEM;
 	}
 
 	list_for_each_entry(device, dev_head, dev_list) {
@@ -1660,7 +1660,7 @@ static int btrfsic_read_block(struct btrfsic_state *state,
 					  sizeof(*block_ctx->pagev)) *
 					 num_pages, GFP_NOFS);
 	if (!block_ctx->mem_to_free)
-		return -1;
+		return -ENOMEM;
 	block_ctx->datav = block_ctx->mem_to_free;
 	block_ctx->pagev = (struct page **)(block_ctx->datav + num_pages);
 	for (i = 0; i < num_pages; i++) {
-- 
2.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1231250 — Re: [PATCH 1/2] btrfs: check-integrity: Fix returned errno codes

FromDavid Sterba <dsterba@suse.cz>
Date2015-09-23 10:50 +0200
SubjectRe: [PATCH 1/2] btrfs: check-integrity: Fix returned errno codes
Message-ID<qbNUw-7t6-49@gated-at.bofh.it>
In reply to#1230454
On Tue, Sep 22, 2015 at 05:29:38PM +0100, Luis de Bethencourt wrote:
> check-integrity is using -1 instead of the -ENOMEM defined macro to
> specify that a buffer allocation failed. Since the error number is
> propagated, the caller will get a -EPERM which is the wrong error
> condition.

Agreed. btrfsic_process_superblock can be called from the mount path so
getting EPERM would be confusing.

> Also, the smatch tool complains with the following warnings:
> btrfsic_process_superblock() warn: returning -1 instead of -ENOMEM is sloppy
> btrfsic_read_block() warn: returning -1 instead of -ENOMEM is sloppy
> 
> Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>

Reviewed-by: David Sterba <dsterba@suse.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1231257

FromDavid Sterba <dsterba@suse.cz>
Date2015-09-23 11:00 +0200
Message-ID<qbO49-7Ek-5@gated-at.bofh.it>
In reply to#1230446
On Tue, Sep 22, 2015 at 05:29:37PM +0100, Luis de Bethencourt wrote:
> These two patches fix instances where -1 is used to specify a buffer
> allocation fail, instead of using -ENOMEM.
> 
> I could merge the two patches into one if that's more appropriate.

No, it's better to change them separately. If you change the return
value, also look at all the callers so you can see the impact of the
change and count that into the "size of the patch".
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web