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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 029FCC6FA82 for ; Wed, 21 Sep 2022 03:14:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230108AbiIUDNf (ORCPT ); Tue, 20 Sep 2022 23:13:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229624AbiIUDNb (ORCPT ); Tue, 20 Sep 2022 23:13:31 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C0D17E02D for ; Tue, 20 Sep 2022 20:13:29 -0700 (PDT) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MXNhb2SDBzpTkt; Wed, 21 Sep 2022 11:10:39 +0800 (CST) Received: from kwepemm600005.china.huawei.com (7.193.23.191) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 21 Sep 2022 11:13:27 +0800 Received: from [10.67.102.118] (10.67.102.118) by kwepemm600005.china.huawei.com (7.193.23.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 21 Sep 2022 11:13:27 +0800 Subject: Re: [PATCH 1/5] hisi_acc_vfio_pci: Fixes a memory leak bug To: Shameerali Kolothum Thodi , "Jason Gunthorpe" , Alex Williamson CC: "cohuck@redhat.com" , "linux-kernel@vger.kernel.org" , "linuxarm@openeuler.org" References: <20220915013157.60771-1-liulongfang@huawei.com> <20220915013157.60771-2-liulongfang@huawei.com> <20220920103443.72654dd7.alex.williamson@redhat.com> <04a17bfa71c440e8a38cba2337a8c6ac@huawei.com> From: liulongfang Message-ID: Date: Wed, 21 Sep 2022 11:13:26 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <04a17bfa71c440e8a38cba2337a8c6ac@huawei.com> Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.118] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600005.china.huawei.com (7.193.23.191) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/9/21 1:03, Shameerali Kolothum Thodi wrote: > > >> -----Original Message----- >> From: Jason Gunthorpe [mailto:jgg@nvidia.com] >> Sent: 20 September 2022 17:38 >> To: Alex Williamson >> Cc: liulongfang ; Shameerali Kolothum Thodi >> ; cohuck@redhat.com; >> linux-kernel@vger.kernel.org; linuxarm@openeuler.org >> Subject: Re: [PATCH 1/5] hisi_acc_vfio_pci: Fixes a memory leak bug >> >> On Tue, Sep 20, 2022 at 10:34:43AM -0600, Alex Williamson wrote: >>> On Thu, 15 Sep 2022 09:31:53 +0800 >>> Longfang Liu wrote: >>> >>>> During the stop copy phase of live migration, the driver allocates a >>>> memory for the migrated data to save the data. >>>> >>>> When an exception occurs when the driver reads device data, the >>>> driver will report an error to qemu and exit the current migration state. >>>> But this memory is not released, which will lead to a memory leak >>>> problem. >> >> Why isn't it released? The fput() releases it: >> >> static int hisi_acc_vf_release_file(struct inode *inode, struct file *filp) { >> struct hisi_acc_vf_migration_file *migf = filp->private_data; >> >> hisi_acc_vf_disable_fd(migf); >> mutex_destroy(&migf->lock); >> kfree(migf); >> ^^^^^^^^^^ >> >> This patch looks wrong to me. > > That's right. Missed that. Sorry of the oversight. > Yes, fput will call release in ops of file, here will call hisi_acc_vf_release_file to complete the release operation of migf, so this patch is unnecessary. But there is another place that needs to be modified: hisi_acc_vf_disable_fd in hisi_acc_vf_disable_fds is not needed, because it will have an fput next. Is this correct? > Thanks, > Shameer > > . Thanks, Longfang. >