Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp3008806pxb; Tue, 12 Jan 2021 04:13:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJxO+TzQ7lZPDnfmguidFvzB2LBcWt3ogqr44tDJzF68YGR5x1y7dbE01Lnypb+gR9MjPb5/ X-Received: by 2002:a17:906:3685:: with SMTP id a5mr2895019ejc.544.1610453634260; Tue, 12 Jan 2021 04:13:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610453634; cv=none; d=google.com; s=arc-20160816; b=WqxMydH/Pn+5konrk7ZfRhGzzz8dvTlJM19YJ+t069uMDhZmt29rX359Vc7bF8AxxW jdo33AaE/V4K72WgldRYtrAWeUNkq2Jz0EB7oCgk8/GNxhVNa5YceUxKxLuKzNJnMQgO fiX+j1IAV/yQxvDKloVSxhGQk9s6ZV9URpY186fF3A60cJD6T80VGiSxiMm0aq8HT7+n G4KKcuguEo/IPnehBjMWMXQtdkst3x5mgevx71KgWtlS+ukTcCQJc79QSsMaTZ3Tf0L2 J5lWEjEX43EC3ljoUvUwa//PNAvUtM8V9VMS2uHNZ/F9wqJPm5I7DZv9sA3QZGTFbl9A vFSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=r3kvVDFWjbr7ryami9ZgvFXha+Kv7sg58qLqlwGPhFY=; b=zXXgkskuJr2LzzPl7FYEv3xxAJiHfzL92Cq1GuRHmwP3X1XYYcsncwpXp/lnHhvYIu x1ryWqk021TWt9aoKM4ghKys7Hdw9lLi8m6sytkM5zyQMS3nE+9hkjApbCQo+wrIcWYx RVj2gsPOkfDfz25ePQdYZU/t1X2pSdy35OzrHA6kJJucydvmC+WgULCz6sWCcBT8qDOu AFvPSv6NBYF21K9wS+4jW8unSEOzlUS2JaF+dNA24gVrksJJcjMpB8RV7/1oaWxcZUYv 26DmyhN2+zF2LZoHZ9lWt6c3CV4Iot+ufOzbwZtANLKQWMPJvUyg+JMNdTuDvy2pWgPd bM1w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg4si1011560ejc.313.2021.01.12.04.13.30; Tue, 12 Jan 2021 04:13:54 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389171AbhALJFP (ORCPT + 99 others); Tue, 12 Jan 2021 04:05:15 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:2310 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727916AbhALJFI (ORCPT ); Tue, 12 Jan 2021 04:05:08 -0500 Received: from fraeml744-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4DFPg63dQ9z67Zyp; Tue, 12 Jan 2021 17:00:34 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml744-chm.china.huawei.com (10.206.15.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 12 Jan 2021 10:04:25 +0100 Received: from [10.210.171.61] (10.210.171.61) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 12 Jan 2021 09:04:24 +0000 Subject: Re: [PATCH v2 1/2] scsi: hisi_sas: Remove unnecessary devm_kfree To: Bean Huo , , , , , , , CC: , , Bean Huo References: <20210111231058.14559-1-huobean@gmail.com> <20210111231058.14559-2-huobean@gmail.com> From: John Garry Message-ID: Date: Tue, 12 Jan 2021 09:03:17 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <20210111231058.14559-2-huobean@gmail.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.210.171.61] X-ClientProxiedBy: lhreml744-chm.china.huawei.com (10.201.108.194) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/01/2021 23:10, Bean Huo wrote: > From: Bean Huo > > The memory allocated with devm_kzalloc() is freed automatically > no need to explicitly call devm_kfree. > This change is not right - we use devm_kfree() to manually release the devm-allocated debugfs memories upon memory allocation failure for driver debugfs feature during probe. The reason is that we allow the driver probe can still continue (for this failure). Thanks, John > Signed-off-by: Bean Huo > --- > drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 28 +------------------------- > 1 file changed, 1 insertion(+), 27 deletions(-) > > diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c > index 91a7286e8102..5600411a0820 100644 > --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c > +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c > @@ -4172,30 +4172,6 @@ static void debugfs_work_handler_v3_hw(struct work_struct *work) > hisi_hba->debugfs_dump_index++; > } > > -static void debugfs_release_v3_hw(struct hisi_hba *hisi_hba, int dump_index) > -{ > - struct device *dev = hisi_hba->dev; > - int i; > - > - devm_kfree(dev, hisi_hba->debugfs_iost_cache[dump_index].cache); > - devm_kfree(dev, hisi_hba->debugfs_itct_cache[dump_index].cache); > - devm_kfree(dev, hisi_hba->debugfs_iost[dump_index].iost); > - devm_kfree(dev, hisi_hba->debugfs_itct[dump_index].itct); > - > - for (i = 0; i < hisi_hba->queue_count; i++) > - devm_kfree(dev, hisi_hba->debugfs_dq[dump_index][i].hdr); > - > - for (i = 0; i < hisi_hba->queue_count; i++) > - devm_kfree(dev, > - hisi_hba->debugfs_cq[dump_index][i].complete_hdr); > - > - for (i = 0; i < DEBUGFS_REGS_NUM; i++) > - devm_kfree(dev, hisi_hba->debugfs_regs[dump_index][i].data); > - > - for (i = 0; i < hisi_hba->n_phy; i++) > - devm_kfree(dev, hisi_hba->debugfs_port_reg[dump_index][i].data); > -} > - > static const struct hisi_sas_debugfs_reg *debugfs_reg_array_v3_hw[DEBUGFS_REGS_NUM] = { > [DEBUGFS_GLOBAL] = &debugfs_global_reg, > [DEBUGFS_AXI] = &debugfs_axi_reg, > @@ -4206,7 +4182,7 @@ static int debugfs_alloc_v3_hw(struct hisi_hba *hisi_hba, int dump_index) > { > const struct hisi_sas_hw *hw = hisi_hba->hw; > struct device *dev = hisi_hba->dev; > - int p, c, d, r, i; > + int p, c, d, r; > size_t sz; > > for (r = 0; r < DEBUGFS_REGS_NUM; r++) { > @@ -4286,8 +4262,6 @@ static int debugfs_alloc_v3_hw(struct hisi_hba *hisi_hba, int dump_index) > > return 0; > fail: > - for (i = 0; i < hisi_sas_debugfs_dump_count; i++) > - debugfs_release_v3_hw(hisi_hba, i); > return -ENOMEM; > } > >