mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roland Scheidegger <sroland@vmware.com>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
	VMware Graphics <linux-graphics-maintainer@vmware.com>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>
Cc: <dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
	"Gustavo A. R. Silva" <gustavo@embeddedor.com>
Subject: Re: [PATCH][next] drm/vmwgfx: Use struct_size() helper
Date: Mon, 22 Jun 2020 17:50:15 +0200	[thread overview]
Message-ID: <4064d1be-a181-039a-5423-34054b631c87@vmware.com> (raw)
In-Reply-To: <20200617215144.GA15547@embeddedor>

I've commited this to our next branch, thanks!
(I'm actually kind of impressed this can be found automatically...)

Roland

Am 17.06.20 um 23:51 schrieb Gustavo A. R. Silva:
> 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>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> index 126f93c0b0b8..3914bfee0533 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> @@ -1969,7 +1969,7 @@ static int vmw_surface_dirty_alloc(struct vmw_resource *res)
>  		num_mip = 1;
>  
>  	num_subres = num_layers * num_mip;
> -	dirty_size = sizeof(*dirty) + num_subres * sizeof(dirty->boxes[0]);
> +	dirty_size = struct_size(dirty, boxes, num_subres);
>  	acc_size = ttm_round_pot(dirty_size);
>  	ret = ttm_mem_global_alloc(vmw_mem_glob(res->dev_priv),
>  				   acc_size, &ctx);
> 


      reply	other threads:[~2020-06-22 15:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-17 21:51 Gustavo A. R. Silva
2020-06-22 15:50 ` Roland Scheidegger [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=4064d1be-a181-039a-5423-34054b631c87@vmware.com \
    --to=sroland@vmware.com \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gustavo@embeddedor.com \
    --cc=gustavoars@kernel.org \
    --cc=linux-graphics-maintainer@vmware.com \
    --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

all inboxes | Powered by JetHome®