Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp543015ybk; Wed, 20 May 2020 06:12:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDDhKzO/v5AfGzAHlO1nUErOJkasWLqOogmm53ttUzovIC4NpaBxnbZcAWYSrNo9D86BJf X-Received: by 2002:a05:6402:357:: with SMTP id r23mr3352656edw.230.1589980372414; Wed, 20 May 2020 06:12:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589980372; cv=none; d=google.com; s=arc-20160816; b=XJghzBNjMAqDf4j4twa0d2IABRCqleZuc84MxVejyWYUOKKYCGVZie3MT2vgpGBxic zl+k+kCDrAjf7Imtmfap/YE7jhaxlsPlDJmbZhJqHkJf4n9HQB8mw3LY/CQu6dzckTXQ WiZR8ENhu6eNHKkJ4H1CEnewoje/8vpLqbmFDPda2LGcWBeBbRN3hr8WCIAqQKczfA4O H7CQTplP61FXsalznF2KYGON5RsCPSBLgqn5iuUW22yxziS4+LVN3hSd9yzs96h1G/1B k9SjwfxwP/hORp7zg+6cU2n8jo9Al2jk1Nmbjb+W3cNH92dJkWiFcQLc8NBeeYHZWoIS zrSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=R7gtf0kiWbCNJ0UhI5MwvQ47qSSl1HmSUaTx5bHu6G0=; b=wZI8btd6Im7tEIMCxcVziLZoy8F4GFgPY04gH5DmT33vXnQB18XH6KVeRf/w4qblUN Jk17chDCEfSO/6jkehm7Gd24YWhsF+G6f4LwJOr226tAizWVFT+ZEwzwP+AX9Ds5xud4 fJN3/HOiBSn5vmd3ELr/ihcA8S4kSvVEqwCwji+fqdzQnDHqHRLvgd54dX0YMYPs6WgC Axxi7/LIzR9wG9jZCr9kvE09t3C0ilQphw/44fstXp/plEQo7cAtcPIrmZez038fvBc7 gYhGanqCKGhxZ3+tXodvS0DVASCz8FSnAGWWlP9m+scN2PeKJuQkGcnHNhcZamcd8Z7q 1wYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=o4m1NTL4; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id le4si1810797ejb.193.2020.05.20.06.12.25; Wed, 20 May 2020 06:12:52 -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=@oracle.com header.s=corp-2020-01-29 header.b=o4m1NTL4; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726693AbgETNKj (ORCPT + 99 others); Wed, 20 May 2020 09:10:39 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:47878 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726439AbgETNKh (ORCPT ); Wed, 20 May 2020 09:10:37 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04KD8JFi064189; Wed, 20 May 2020 13:10:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=R7gtf0kiWbCNJ0UhI5MwvQ47qSSl1HmSUaTx5bHu6G0=; b=o4m1NTL434XJQbAkIuOB//h3s4FworvA3R42ve4vzv2KBNyiMoH/EbmcxuhOlXbZd+A9 vJW4rNRvhlnDIx2czecGKoM7wSEB7Cm4Lt0EGB05DA1cOixhUrZ2Uk434gcFJoJr4h30 EvBTF06GCH/PagknjE+aV2ROHM1ySQqhjKRMgDwfwkqEXlYbNtDw4UfSzcqXBnc626oh rQYKowjZKekgM+ykGLa/pW7YGTtZdX3t4A6hKcwuW799AcWvhQafXS7J6Ej6Nl/+rxAb sKyP2sKE+2DnK+TCtqHM1Hz9D1ld0gFjEnAevWLNbstcYQpLpg0tNinE6yVGMpu3/Tst GQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 3127krb14d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 20 May 2020 13:10:32 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04KD8SBh188047; Wed, 20 May 2020 13:08:31 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 314gm724eb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 May 2020 13:08:30 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 04KD8Lud010719; Wed, 20 May 2020 13:08:21 GMT Received: from mwanda (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 20 May 2020 06:08:20 -0700 Date: Wed, 20 May 2020 16:08:12 +0300 From: Dan Carpenter To: Alex Deucher , Kevin Wang Cc: Christian =?iso-8859-1?Q?K=F6nig?= , 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 v2] drm/amdgpu: off by on in amdgpu_device_attr_create_groups() error handling Message-ID: <20200520130812.GA177222@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200520125209.GP3041@kadam> X-Mailer: git-send-email haha only kidding X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9626 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 adultscore=0 phishscore=0 mlxscore=0 spamscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005200113 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9626 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 spamscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 impostorscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 cotscore=-2147483648 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005200113 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This loop in the error handling code should start a "i - 1" and end at "i == 0". Currently it starts a "i" and ends at "i == 1". 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 attribute code") Signed-off-by: Dan Carpenter --- v2: style change 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(struct amdgpu_device *adev, return 0; failed: - for (; i > 0; i--) { + while (i--) amdgpu_device_attr_remove(adev, &attrs[i]); - } return ret; }