From nobody Sun Apr 5 16:28:55 2026 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 3279FECAAD3 for ; Thu, 15 Sep 2022 01:35:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229729AbiIOBfO (ORCPT ); Wed, 14 Sep 2022 21:35:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229701AbiIOBfL (ORCPT ); Wed, 14 Sep 2022 21:35:11 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC9522980C for ; Wed, 14 Sep 2022 18:35:10 -0700 (PDT) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MSfmp5ZD0zmVNH; Thu, 15 Sep 2022 09:31:22 +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.24; Thu, 15 Sep 2022 09:35:08 +0800 Received: from huawei.com (10.69.192.56) 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; Thu, 15 Sep 2022 09:35:08 +0800 From: Longfang Liu To: , , CC: , , , Subject: [PATCH 1/5] hisi_acc_vfio_pci: Fixes a memory leak bug Date: Thu, 15 Sep 2022 09:31:53 +0800 Message-ID: <20220915013157.60771-2-liulongfang@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220915013157.60771-1-liulongfang@huawei.com> References: <20220915013157.60771-1-liulongfang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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 Content-Type: text/plain; charset="utf-8" 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. So we need to add a memory release operation. Reviewed-by: Shameer Kolothum Signed-off-by: Longfang Liu --- drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c b/drivers/vfio/= pci/hisilicon/hisi_acc_vfio_pci.c index ea762e28c1cc..8fd68af2ed5f 100644 --- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c @@ -828,15 +828,15 @@ hisi_acc_vf_stop_copy(struct hisi_acc_vf_core_device = *hisi_acc_vdev) return ERR_PTR(err); } =20 - stream_open(migf->filp->f_inode, migf->filp); - mutex_init(&migf->lock); - ret =3D vf_qm_state_save(hisi_acc_vdev, migf); if (ret) { - fput(migf->filp); + kfree(migf); return ERR_PTR(ret); } =20 + stream_open(migf->filp->f_inode, migf->filp); + mutex_init(&migf->lock); + return migf; } =20 --=20 2.33.0