All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Geliang Tang <geliangtang@163.com>
Cc: Minchan Kim <minchan@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] zram: fix memory freeing in zram_meta_alloc
Date: Mon, 9 Nov 2015 09:33:32 +0900	[thread overview]
Message-ID: <20151109003332.GA471@swordfish> (raw)
In-Reply-To: <325e5c0cbcc756b88dfc78b6d9388c07be7aa8f1.1446996521.git.geliangtang@163.com>

On (11/08/15 23:32), Geliang Tang wrote:
> When meta->table is NULL, there is no need to vfree it.
> 

Hi,

So what's the benefit? It's ok to pass a NULL pointer to vfree(). Why
would we add another label? To avoid a valid call on error path?

	-ss

> Signed-off-by: Geliang Tang <geliangtang@163.com>
> ---
>  drivers/block/zram/zram_drv.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index 81a557c..197a7ad 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -511,7 +511,7 @@ static struct zram_meta *zram_meta_alloc(char *pool_name, u64 disksize)
>  	meta->table = vzalloc(num_pages * sizeof(*meta->table));
>  	if (!meta->table) {
>  		pr_err("Error allocating zram address table\n");
> -		goto out_error;
> +		goto out_free;
>  	}
>  
>  	meta->mem_pool = zs_create_pool(pool_name, GFP_NOIO | __GFP_HIGHMEM);
> @@ -524,6 +524,7 @@ static struct zram_meta *zram_meta_alloc(char *pool_name, u64 disksize)
>  
>  out_error:
>  	vfree(meta->table);
> +out_free:
>  	kfree(meta);
>  	return NULL;
>  }
> -- 
> 2.5.0
> 
> 

      parent reply	other threads:[~2015-11-09  0:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-08 15:32 [PATCH 1/2] zram: fix memory freeing in zram_meta_alloc Geliang Tang
2015-11-08 15:32 ` [PATCH 2/2] zram: fix memory freeing in zram_bvec_read Geliang Tang
2015-11-09  0:42   ` Sergey Senozhatsky
2015-11-09  0:33 ` Sergey Senozhatsky [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151109003332.GA471@swordfish \
    --to=sergey.senozhatsky.work@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=geliangtang@163.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.