linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] btrfs: fix check for memory allocation failure of ret->path
@ 2020-04-21 12:47 Colin King
  2020-04-21 12:48 ` Qu Wenruo
  2020-04-27 15:18 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2020-04-21 12:47 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, Johannes Thumshirn,
	Qu Wenruo, linux-btrfs
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently the memory allocation failure check for ret->path is checking
that ret is null rather than ret->path.  Fix this by checking ret->path
instead.

Addresses-Coverity: ("Dereference null return")
Fixes: bd8bdc532152 ("btrfs: backref: introduce the skeleton of btrfs_backref_iter")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/btrfs/backref.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 60a69f7c0b36..78e6c9a64212 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -2307,7 +2307,7 @@ struct btrfs_backref_iter *btrfs_backref_iter_alloc(
 		return NULL;
 
 	ret->path = btrfs_alloc_path();
-	if (!ret) {
+	if (!ret->path) {
 		kfree(ret);
 		return NULL;
 	}
-- 
2.25.1


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

* Re: [PATCH][next] btrfs: fix check for memory allocation failure of ret->path
  2020-04-21 12:47 [PATCH][next] btrfs: fix check for memory allocation failure of ret->path Colin King
@ 2020-04-21 12:48 ` Qu Wenruo
  2020-04-27 15:18 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2020-04-21 12:48 UTC (permalink / raw)
  To: Colin King, Chris Mason, Josef Bacik, David Sterba,
	Johannes Thumshirn, linux-btrfs
  Cc: kernel-janitors, linux-kernel



On 2020/4/21 下午8:47, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the memory allocation failure check for ret->path is checking
> that ret is null rather than ret->path.  Fix this by checking ret->path
> instead.
> 
> Addresses-Coverity: ("Dereference null return")
> Fixes: bd8bdc532152 ("btrfs: backref: introduce the skeleton of btrfs_backref_iter")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

My bad.

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>  fs/btrfs/backref.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
> index 60a69f7c0b36..78e6c9a64212 100644
> --- a/fs/btrfs/backref.c
> +++ b/fs/btrfs/backref.c
> @@ -2307,7 +2307,7 @@ struct btrfs_backref_iter *btrfs_backref_iter_alloc(
>  		return NULL;
>  
>  	ret->path = btrfs_alloc_path();
> -	if (!ret) {
> +	if (!ret->path) {
>  		kfree(ret);
>  		return NULL;
>  	}
> 

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

* Re: [PATCH][next] btrfs: fix check for memory allocation failure of ret->path
  2020-04-21 12:47 [PATCH][next] btrfs: fix check for memory allocation failure of ret->path Colin King
  2020-04-21 12:48 ` Qu Wenruo
@ 2020-04-27 15:18 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2020-04-27 15:18 UTC (permalink / raw)
  To: Colin King
  Cc: Chris Mason, Josef Bacik, David Sterba, Johannes Thumshirn,
	Qu Wenruo, linux-btrfs, kernel-janitors, linux-kernel

On Tue, Apr 21, 2020 at 01:47:03PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the memory allocation failure check for ret->path is checking
> that ret is null rather than ret->path.  Fix this by checking ret->path
> instead.
> 
> Addresses-Coverity: ("Dereference null return")
> Fixes: bd8bdc532152 ("btrfs: backref: introduce the skeleton of btrfs_backref_iter")

As this is still in development branch, fixup folded in. Thanks.

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

end of thread, other threads:[~2020-04-27 15:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-21 12:47 [PATCH][next] btrfs: fix check for memory allocation failure of ret->path Colin King
2020-04-21 12:48 ` Qu Wenruo
2020-04-27 15:18 ` 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).