Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp646748ybk; Wed, 20 May 2020 08:30:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw28EZjPruTjpYMbofBWYvJ09P6/dALgdLCmrz6N09uZeSV1s5ftwJhx0frIQZKQJYJfHfz X-Received: by 2002:aa7:d787:: with SMTP id s7mr4024128edq.104.1589988605999; Wed, 20 May 2020 08:30:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589988605; cv=none; d=google.com; s=arc-20160816; b=piVT7cNnIevXoBmWq1rvJ0vJrIqtCh2CaJ5n098mjtC7VNumTSlbPty2gsxpk3RjP5 sHAMctaOgdzn0FrgR5TUPAR/w/qmNqo9Nm5E5cv1gseMKnNQiwJMwH1ypz2ijLsbyHlr S/w6Q9PcE9JYESrEOAtjqHScnQCgG3PvL80B/IK3nM9yABE2xPJfXksa4XHK+NvOLOp8 c/JaHIM40IHEU6dOc4TsH4a8Y6Q0Ap5WaVCt44EnN4K1Y5E5zVYseC3cn4yG65jWBTgr vAJ09AQZw3a9hI/Zxy7cDDWUe7HP04xmeeI1oGcqEk/s/ea8YBkFYiU+AGVRxDMQ0QKs A99g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=us1UyD3eb7iJfl6Z3bLFPAGiXiDBjSZBmVmqk0QGUNc=; b=WeBqU81h/vHh0EVv+TSEpjTMS7CCE3L/QaG0NXpj25N3W+1gOlWkbVALIMx3F4htVI coLs9A/MlJSQ/eFLxw1iqbLt2wdRDwDMsWj34v6+6QVhqY3uVfr1omMpt1WYO2zax5/D TRHEMX1Yc9bbtrE09HQQDoj657VijXDISQAqL8GEd3HjthQtKzGXLZ69RBmWEW3dUY/x p48iP4D/Fx7+y1xiICLH8OIrQL7EC1VhrsqqApI5JLOOOZRiGdb/Wg+5+0QeBnY3E79e PNqp+qAMzbBeamQ/ylPZeweVdBPbTnFGuSJVnRQCIPv2T+IAWg41HdsZq0gsse0Ow4rD AxAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=UmPc6+0i; 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 e1si1764866ejr.438.2020.05.20.08.29.42; Wed, 20 May 2020 08:30:05 -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=UmPc6+0i; 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 S1726818AbgETP0R (ORCPT + 99 others); Wed, 20 May 2020 11:26:17 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:38404 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726436AbgETP0Q (ORCPT ); Wed, 20 May 2020 11:26:16 -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 04KFHG6Q076583; Wed, 20 May 2020 15:26:08 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=us1UyD3eb7iJfl6Z3bLFPAGiXiDBjSZBmVmqk0QGUNc=; b=UmPc6+0inQWEbzaEFKEDNeJN07Gfg3Bdl2wV+TyTbU5NkKVJ6Hx3iAm/EaPnOyR/jOEn 76Pfbs1ruJ7tsNc0QBUyziXvPqqsmY8SPpgLiDVq16zOvWY2DX1e9A1ryFnAi2RRgNEN m45kXwrhzEg6acq1hoWDsR/KGhgAAoNw70G8rilJCCYOscqDUhdQ4BqOyWB1ddhTGs80 XROz97K0j3kT2CPv6tUEuthNw2V1VirUGDIxOD50SBWJAtPIIawV6B8/owzeIFYO9IJg WOTBz34LwPsGNZrptphJoHlCT9IQOi55XukGq+r0bKv2NgSkzKvhXZPWa+xiGXOXocVd dQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 3127krbt8s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 20 May 2020 15:26:08 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04KFD8pI058218; Wed, 20 May 2020 15:26:08 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 312t37xnad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 May 2020 15:26:06 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 04KFQ5bw026329; Wed, 20 May 2020 15:26:05 GMT Received: from kadam (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 20 May 2020 08:26:04 -0700 Date: Wed, 20 May 2020 18:25:56 +0300 From: Dan Carpenter To: Alex Deucher , Kevin Wang , "Ruhl, Michael J" 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 v3] drm/amdgpu: off by one in amdgpu_device_attr_create_groups() error handling Message-ID: <20200520152556.GQ3041@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <14063C7AD467DE4B82DEDB5C278E8663010E2302FA@FMSMSX108.amr.corp.intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9626 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 malwarescore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005200126 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=1011 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-2005200126 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 v3: Fix embarrassing typo in the subject 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; }