Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2864734ybt; Mon, 22 Jun 2020 08:54:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/6NoS/HOH7cOIkOW5Cf1jPxfsKiYLmU1N3ZN6Us2t7iEl117sydsqBq3X64VoBoCQQEpN X-Received: by 2002:aa7:c752:: with SMTP id c18mr17201137eds.55.1592841269987; Mon, 22 Jun 2020 08:54:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592841269; cv=none; d=google.com; s=arc-20160816; b=acBEzaRj3fswiKYz5QyGJ6TgsimKYjykKjBu+A6pLpkDDdCZ6xmy1WwPKdrpzmpXCH JM2ODAaVfgBNfU8SG/xlgf8+2AKGT4c+OPZyISi7ACYe5wT1pTJAMIBJv67YsslSeMjT anwbfnVwIlWGs19kRVTNh9utjUGms2iR2h6l/Vlbpx1rmtEjK4kBMttPUUlkZ03kas0L JqpbHefnc5l2GBNuiVyVq5CA/VphDhWs2adxJKfh2TE0oCSBoAFTiDL8LyKxtY34KVKQ pJ1WMBGNYozBB8rATQTDSLxRrjhrhNYmNxn89jOGNUI3mZBmWa+VahGvNMLxa+KcbFsS YxWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=m8Kq0ShFrsBLuCJhdhIAR9eVXzzurboZaRGonlcGoZc=; b=JiplfBgFrWw7/04P9rZQI5d62J8luLv7LwWOqpgVeMpCXTlKtrZqg/i73epKRzDvOD 3otDE34xCpTV7fi8YRtAdJubJ2v7FAbGep5CEEeLWt1UigtllCa7NtOucC6Lx61SBHDe QmX995uGc3h8iOzJJs2d40UUOuG8DNd6YY6HJfujy+WUqbNG4W7cGc/adLYA546b4ZBZ U/Z325Cqp9LTbiiPrFqUGLtWMh81yvhG7XUpHr9p6ePMo4fzW1snvIhjBq1PxulGKXXP I2/5maE8rARZcnWELN3OAr8f+lB+JRSEBRmkWIqgopC9PrkQhgC/KoPHtQdM2OyYzQUn DV4Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i23si3083745edx.261.2020.06.22.08.54.08; Mon, 22 Jun 2020 08:54:29 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729458AbgFVPuS (ORCPT + 99 others); Mon, 22 Jun 2020 11:50:18 -0400 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:29100 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728293AbgFVPuS (ORCPT ); Mon, 22 Jun 2020 11:50:18 -0400 Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Mon, 22 Jun 2020 08:50:16 -0700 Received: from [0.0.0.0] (oddjob.vmware.com [10.253.4.32]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id EACDCB2759; Mon, 22 Jun 2020 11:50:15 -0400 (EDT) Subject: Re: [PATCH][next] drm/vmwgfx: Use struct_size() helper To: "Gustavo A. R. Silva" , VMware Graphics , David Airlie , Daniel Vetter CC: , , "Gustavo A. R. Silva" References: <20200617215144.GA15547@embeddedor> From: Roland Scheidegger Message-ID: <4064d1be-a181-039a-5423-34054b631c87@vmware.com> Date: Mon, 22 Jun 2020 17:50:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200617215144.GA15547@embeddedor> Content-Type: text/plain; charset="utf-8" Content-Language: de-DE Content-Transfer-Encoding: 7bit Received-SPF: None (EX13-EDG-OU-001.vmware.com: sroland@vmware.com does not designate permitted sender hosts) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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); >