From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964992AbeALRtC (ORCPT + 1 other); Fri, 12 Jan 2018 12:49:02 -0500 Received: from mga05.intel.com ([192.55.52.43]:1092 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964844AbeALRtB (ORCPT ); Fri, 12 Jan 2018 12:49:01 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,350,1511856000"; d="scan'208";a="18743443" Subject: Re: [Intel-gfx] [PATCH][next] drm/i915/pmu: fix sizeof on attr, should be *attr To: Colin King , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180112173603.28486-1-colin.king@canonical.com> From: Tvrtko Ursulin Message-ID: <1465951f-474c-e157-892b-33d12ad436cb@linux.intel.com> Date: Fri, 12 Jan 2018 17:48:57 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180112173603.28486-1-colin.king@canonical.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Hi, On 12/01/2018 17:36, Colin King wrote: > From: Colin Ian King > > I believe the sizeof(attr) should be in fact sizeof(*attr), fortunately > the current code works because sizeof(struct attribute **) is the same > as sizeof(struct attribute *) for x86. Thanks, kbuild also reported it and I just pushed a fix. Out of curiosity, there are platforms where size of pointer is different from the size of a pointer to a pointer? Regards, Tvrtko > > Detected by CoverityScan, CID#1463854 ("Sizeof not portable") > > Fixes: 109ec558370f ("drm/i915/pmu: Only enumerate available counters in sysfs") > Signed-off-by: Colin Ian King > --- > drivers/gpu/drm/i915/i915_pmu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c > index 95ab5e28f5be..9be4f5201e41 100644 > --- a/drivers/gpu/drm/i915/i915_pmu.c > +++ b/drivers/gpu/drm/i915/i915_pmu.c > @@ -794,7 +794,7 @@ create_event_attributes(struct drm_i915_private *i915) > goto err_alloc; > > /* Max one pointer of each attribute type plus a termination entry. */ > - attr = kzalloc((count * 2 + 1) * sizeof(attr), GFP_KERNEL); > + attr = kzalloc((count * 2 + 1) * sizeof(*attr), GFP_KERNEL); > if (!attr) > goto err_alloc; > >