From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D23AC433DF for ; Wed, 20 May 2020 18:39:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5407D2072C for ; Wed, 20 May 2020 18:39:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mGZn3LCw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5407D2072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CC2846E881; Wed, 20 May 2020 18:39:18 +0000 (UTC) Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id E57A56E881; Wed, 20 May 2020 18:39:17 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id k13so4231808wrx.3; Wed, 20 May 2020 11:39:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZwIuzGd2VX1FSb5QhuGSYUs3g1lNhtaIqItKH1fDEjI=; b=mGZn3LCwrh1er7h+5mKGAGnnUY2Ks67cnyDOnBxr6ppvmQaNF1P4xZD9PG77BNsHmu S5/qN42Uc+eswztsLOtgjGyQQYst2CUxZrUCtpWPxOMizZJKCYiPAfbj91UdefSTXdX8 t/iETTcwZJx7h/ZNkrfZ7Q9udJvEv2w1wni0GhEvDnVTexG7fBXG2KZpoz2eVZ9nMB5P gkFdi1QuziNNU3q6MbXQcSiGtmT86Rd3RclN9fba4MXBjWX0KWPBUcxVtoB5rax9Dz6+ 5/Pawel55bQUCYz8RQkmqxbeM4XjJhRAd6qP17sLiHymK93zWK/q10L2I0ckj93RC4oY JSdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZwIuzGd2VX1FSb5QhuGSYUs3g1lNhtaIqItKH1fDEjI=; b=BXtuh8+lGEL/tno58PawNw6QIMBRDVCYC6+PLwgSfeCz5ASoiqBHrQJog6ECLIkwNG CS/k1NgqBx0vYYdIXlltAx+AmoeyrDN+8SzHTXOpFyL2cmM3tZ8AAu2u2KZ9KMdqYTsj kGPHiCWo42II3PtydQe+7W28Fd8HydqyHx/xcbujd2RKNqmNq+RuPgy49abUb/vUAXFw uwFlqdMMSUp3X1fidwZBvNSyooFXusZrK70zxlUR3/9eKoGWRtCxuoy+vtyR1GsqDSL7 8Iq3cDyF7Qenn3hREP7ALIyGLssDYLVleZFLKKFGl5iQbWaCHVehI6wca2GH4ZpO2RHk oeWA== X-Gm-Message-State: AOAM532AMOuugyIAyBST2bFl7Wd2y+Lk9R2/OpYwt+wnmvbKowCIB6Gv gH4uiFAyTcbQAl5gixNcvRce4XVSeub01gNMdQ0= X-Google-Smtp-Source: ABdhPJz0f3WzpHZv2xwvWJxbBl9OkgDh76FfraQ17OtQuyrtc4H+ZBzelteOn/XG3GWz2fma8XDzx+fOhclYlv51KeM= X-Received: by 2002:a05:6000:14b:: with SMTP id r11mr5639767wrx.124.1589999956571; Wed, 20 May 2020 11:39:16 -0700 (PDT) MIME-Version: 1.0 References: <14063C7AD467DE4B82DEDB5C278E8663010E2302FA@FMSMSX108.amr.corp.intel.com> <20200520152556.GQ3041@kadam> <14063C7AD467DE4B82DEDB5C278E8663010E230378@FMSMSX108.amr.corp.intel.com> In-Reply-To: From: Alex Deucher Date: Wed, 20 May 2020 14:39:04 -0400 Message-ID: Subject: Re: [PATCH v3] drm/amdgpu: off by one in amdgpu_device_attr_create_groups() error handling To: =?UTF-8?Q?Christian_K=C3=B6nig?= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , Kevin Wang , "kernel-janitors@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "amd-gfx@lists.freedesktop.org" , "Ruhl, Michael J" , Rui Huang , "dri-devel@lists.freedesktop.org" , Alex Deucher , Yintian Tao , Evan Quan , Kenneth Feng , Dan Carpenter , Hawking Zhang Content-Type: multipart/mixed; boundary="===============1130259701==" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" --===============1130259701== Content-Type: multipart/alternative; boundary="0000000000009ab89e05a618b642" --0000000000009ab89e05a618b642 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Applied. Thanks! Alex On Wed, May 20, 2020 at 11:33 AM Christian K=C3=B6nig wrote: > Am 20.05.20 um 17:31 schrieb Ruhl, Michael J: > >> -----Original Message----- > >> From: Dan Carpenter > >> Sent: Wednesday, May 20, 2020 11:26 AM > >> To: Alex Deucher ; Kevin Wang > >> ; Ruhl, Michael J > >> Cc: Christian K=C3=B6nig ; David Airlie > >> ; Daniel Vetter ; Evan Quan > >> ; Rui Huang ; Kenneth Feng > >> ; Yintian Tao ; Hawking Zhang > >> ; amd-gfx@lists.freedesktop.org; dri- > >> devel@lists.freedesktop.org; linux-kernel@vger.kernel.org; kernel- > >> janitors@vger.kernel.org > >> Subject: [PATCH v3] drm/amdgpu: off by one in > >> amdgpu_device_attr_create_groups() error handling > >> > >> This loop in the error handling code should start a "i - 1" and end at > >> "i =3D=3D 0". Currently it starts a "i" and ends at "i =3D=3D 1". Th= e result > >> is that it removes one attribute that wasn't created yet, and leaks th= e > >> zeroeth attribute. > >> > >> Fixes: 4e01847c38f7 ("drm/amdgpu: optimize amdgpu device attribute > code") > >> Signed-off-by: Dan Carpenter > >> --- > >> v2: style change > >> v3: Fix embarrassing typo in the subject > > =F0=9F=98=8A > > > > Acked-by: Michael J. Ruhl > > Reviewed-by: Christian K=C3=B6nig > > > > > m > >> drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 3 +-- > >> 1 files changed, 1 insertions(+), 2 deletions(-) > >> > >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c > >> b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c > >> index b75362bf0742..e809534fabd4 100644 > >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c > >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c > >> @@ -1942,9 +1942,8 @@ static int amdgpu_device_attr_create_groups(stru= ct > >> amdgpu_device *adev, > >> return 0; > >> > >> failed: > >> - for (; i > 0; i--) { > >> + while (i--) > >> amdgpu_device_attr_remove(adev, &attrs[i]); > >> - } > >> > >> return ret; > >> } > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel > --0000000000009ab89e05a618b642 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Applied.=C2=A0 Thanks!

Alex<= br>

On Wed, May 20, 2020 at 11:33 AM Christian K=C3=B6nig <christian.koenig@amd.com> wrote= :
Am 20.05.20 um= 17:31 schrieb Ruhl, Michael J:
>> -----Original Message-----
>> From: Dan Carpenter <dan.carpenter@oracle.com>
>> Sent: Wednesday, May 20, 2020 11:26 AM
>> To: Alex Deucher <alexander.deucher@amd.com>; Kevin Wang
>> <kevin= 1.wang@amd.com>; Ruhl, Michael J <michael.j.ruhl@intel.com>
>> Cc: Christian K=C3=B6nig <christian.koenig@amd.com>; David Airlie
>> <airlied@= linux.ie>; Daniel Vetter <daniel@ffwll.ch>; Evan Quan
>> <evan.qu= an@amd.com>; Rui Huang <ray.huang@amd.com>; Kenneth Feng
>> <kenn= eth.feng@amd.com>; Yintian Tao <yttao@amd.com>; Hawking Zhang
>> <Haw= king.Zhang@amd.com>; amd-gfx@lists.freedesktop.org; dri-
>> d= evel@lists.freedesktop.org; linux-kernel@vger.kernel.org; kernel-
>> jani= tors@vger.kernel.org
>> Subject: [PATCH v3] drm/amdgpu: off by one in
>> amdgpu_device_attr_create_groups() error handling
>>
>> This loop in the error handling code should start a "i - 1&qu= ot; and end at
>> "i =3D=3D 0".=C2=A0 Currently it starts a "i" = and ends at "i =3D=3D 1".=C2=A0 The result
>> is that it removes one attribute that wasn't created yet, and = leaks the
>> zeroeth attribute.
>>
>> Fixes: 4e01847c38f7 ("drm/amdgpu: optimize amdgpu device attr= ibute code")
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>> ---
>> v2: style change
>> v3: Fix embarrassing typo in the subject
> =F0=9F=98=8A
>
> Acked-by: Michael J. Ruhl <michael.j.ruhl@intel.com>

Reviewed-by: Christian K=C3=B6nig <christian.koenig@amd.com>

>
> m
>> drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0| 3 +--
>> 1 files changed, 1 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
>> index b75362bf0742..e809534fabd4 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
>> @@ -1942,9 +1942,8 @@ static int amdgpu_device_attr_create_groups(= struct
>> amdgpu_device *adev,
>>=C2=A0 =C2=A0 =C2=A0 return 0;
>>
>> failed:
>> -=C2=A0 =C2=A0 for (; i > 0; i--) {
>> +=C2=A0 =C2=A0 while (i--)
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 amdgpu_device_attr= _remove(adev, &attrs[i]);
>> -=C2=A0 =C2=A0 }
>>
>>=C2=A0 =C2=A0 =C2=A0 return ret;
>> }

_______________________________________________
dri-devel mailing list
dri-de= vel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listin= fo/dri-devel
--0000000000009ab89e05a618b642-- --===============1130259701== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel --===============1130259701==--