linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Coly Li <colyli@suse.de>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Kent Overstreet <kent.overstreet@gmail.com>,
	linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Gustavo A. R. Silva" <gustavo@embeddedor.com>
Subject: Re: [PATCH][next] bcache: movinggc: Use struct_size() helper in kzalloc()
Date: Sat, 20 Jun 2020 22:17:20 +0800	[thread overview]
Message-ID: <de0eb477-35a5-9849-55c5-1b782fc3cec3@suse.de> (raw)
In-Reply-To: <20200617223331.GA25794@embeddedor>

On 2020/6/18 06:33, Gustavo A. R. Silva wrote:
> Make use of the struct_size() helper instead of an open-coded version
> in order to avoid any potential type mistakes.
> 
> This code was detected with the help of Coccinelle and, audited and
> fixed manually.
> 
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>

The patch looks good to me, and I assume you already test and verify the
change. I will add them in my for-test directory.

Thanks.

Coly Li

> ---
>  drivers/md/bcache/movinggc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c
> index 7891fb512736..b7dd2d75f58c 100644
> --- a/drivers/md/bcache/movinggc.c
> +++ b/drivers/md/bcache/movinggc.c
> @@ -145,8 +145,8 @@ static void read_moving(struct cache_set *c)
>  			continue;
>  		}
>  
> -		io = kzalloc(sizeof(struct moving_io) + sizeof(struct bio_vec)
> -			     * DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS),
> +		io = kzalloc(struct_size(io, bio.bio.bi_inline_vecs,
> +					 DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS)),
>  			     GFP_KERNEL);
>  		if (!io)
>  			goto err;
> 


      reply	other threads:[~2020-06-22 14:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-17 22:33 [PATCH][next] bcache: movinggc: Use struct_size() helper in kzalloc() Gustavo A. R. Silva
2020-06-20 14:17 ` Coly Li [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=de0eb477-35a5-9849-55c5-1b782fc3cec3@suse.de \
    --to=colyli@suse.de \
    --cc=gustavo@embeddedor.com \
    --cc=gustavoars@kernel.org \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-kernel@vger.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 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).