Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp812007ybt; Wed, 17 Jun 2020 14:50:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwI2e+rb8ANkti6MYxeoxr8XaPjJJ3sWZqNLM3ts8uY6i21SSD/ORAjAKZ3UsSQJVm0JhPO X-Received: by 2002:a17:906:370a:: with SMTP id d10mr1097853ejc.433.1592430656539; Wed, 17 Jun 2020 14:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592430656; cv=none; d=google.com; s=arc-20160816; b=KJf2CbRMbEOVgBtx94zGV3NTMAV6g463UMCoZ8DVgYbfHCxB6lNrCni4gIGAplr5dr AswslOdf5gTFydNgi4PDBsDZjX85Zy6YOw6x3bKj2NOhtssas4sPfhVGRKzlO9XEhRSf IxbHHZPxriYsacEhPocaENIcQ0JtkPnb9lodiNRukBW4njJCPml4p2A2UoOt1dS7vo5/ UADUzyGqw5XRUa5ZSwkR0zyspGGNpWvN5s/csJDpCLmcAkUD3JcTznp6BeG4yY4dVwZG opKNAkRvsOZXkHA4ch/Ox2WDNsmHkhIjwuIqAU7cnccmVUwBt5K5sZPpb5M39Cnyui+0 dU/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=F4R8VPguyReEjHUWsjOEeocAGauqbday1MzIQqBQfg8=; b=aQn7LrQX1Z+rSeVdq6h3kDBzMspqqX66FpdkeGBQ7ck90unRd83Ax4WnYuZ/lgLpOd L6PuJ/sqhiAtRTFiSKqWA56wCkD0NLUbIWK0vSQWhcdRcXt70wbXNE5EFEiEC9CFUuC9 j9MyzUtVT0QqxTygoBydB6GWBSvY7u0ngiO3Sy24AWBbk496kpA21XiExospGk9BRjf/ n4kkg/DKQIsVksSoFSgE62TX33aGYaMcVDZK6a3C+vDyI6cJ+VLSzCs4Jt9eTuy7ZVMA 1ysfGAen5ZtXAozZCw1re5Vlb1qQVRYrAJ6XhfP7o8gLIplp+s//ul5MvVJPUcDUvPt/ bePg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f87SYItZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bc22si745104edb.368.2020.06.17.14.50.34; Wed, 17 Jun 2020 14:50:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f87SYItZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727047AbgFQVqZ (ORCPT + 99 others); Wed, 17 Jun 2020 17:46:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:34876 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726763AbgFQVqY (ORCPT ); Wed, 17 Jun 2020 17:46:24 -0400 Received: from embeddedor (unknown [189.207.59.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7CFAE2070A; Wed, 17 Jun 2020 21:46:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592430384; bh=UbiWUnRCkAGGdldl4FnZG+4FjPU7hucL7ZHTarruCGY=; h=Date:From:To:Cc:Subject:From; b=f87SYItZuGTNKJh02sXVIPBzJpsmgkahJtpOr0RouYOG8QfVe/sEaNYeO9Kvil2ch AXSPNMa8agohwn8Iivxu5YM4ZkLZpCOoctwMJO7/b1TrKHBEh2dMFnt4xWBdEl5ndN EIhPcioC/TMCpwCewUVkAQxYG9SHOmbqfINgqMas= Date: Wed, 17 Jun 2020 16:51:44 -0500 From: "Gustavo A. R. Silva" To: VMware Graphics , Roland Scheidegger , David Airlie , Daniel Vetter Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH][next] drm/vmwgfx: Use struct_size() helper Message-ID: <20200617215144.GA15547@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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); -- 2.27.0