Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp4760842rwb; Tue, 20 Sep 2022 20:25:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7+RmUgfs8LgSlm1VdtJyfV1fxS0hl7f3AEdv7pFPWCguP/GUVgCAR+uRqJ4pbxxKEZjezs X-Received: by 2002:a17:902:f547:b0:178:39fe:5b14 with SMTP id h7-20020a170902f54700b0017839fe5b14mr2750235plf.100.1663730754473; Tue, 20 Sep 2022 20:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663730754; cv=none; d=google.com; s=arc-20160816; b=CPhoxEE+YZDQXTWnVKt8PzRbo0U1jOXAVkug47q1RnzaLCc4YH4OxdM8MnQUfE5j8/ QPQRTzmRsxL7R/GcLxMvUp5PTPIlDxwEzVjjEmIg9H145PlEOPJk4k1Fn9hAZXT9AuxL Qm0inbH6FJudviMoDlNU4sf0mNd2hCFLCCYqeuHwlElv9YTutvHwoLv3PqV0PTooKk5w sZUx1Qmo2yfqoWrSakk0h5kNSxnxuB9nCWbzkUlz+ePhVpMcttXggjtrWRrBH1fa235E wx0gRgaxNKK7YWziaYb18ZZ2xSCtUCmabYNhQvHyPEtdmgjH8L4vFsNrYcHT92PDtbfL g3WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=jIy2k3x9dGGaEbIrnxtmCQlb4mjH6EAl0h+32GeNWeo=; b=ky2UGo0ch6OH/ZO4EHSc+zhhPQQe82jyYZtpIwOm8vJPjHHtYln3Zp7tGRPnVLvltQ tMOMAJAC6ZJLGwLE7L3I73nXHv7OfXQKJHdbDcEsT6FT8UTFfi08Fwlkf+474pEIARoE yBWppmekEO+pezR2XmXHo049/JyigUy5RhUcPfU5bCodb2apWw44xZXVmcjsAhF4hm7/ F16pF7Wcx5e/Boj3sd3fMjirhUckXR+NpBy0rNlViT5vRhWgV4eHC1weGoFlVztG+xCc oO8dI/YXxBejnrZSKZvCTlIWvd55By3LgpkwN8F27pidHsdkgOH/rlYb6qxnEd5NtjZC PMKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z17-20020aa79f91000000b0053840181203si1540282pfr.117.2022.09.20.20.25.43; Tue, 20 Sep 2022 20:25:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229845AbiIUDNe (ORCPT + 99 others); Tue, 20 Sep 2022 23:13:34 -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 X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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. >