Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2716449imm; Tue, 4 Sep 2018 08:54:37 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb6K3opqDsLkfPvrCWSYdjoLkTzCnNgSei1eQNQJDgi25PiLbWYCPElxr0CrtQuYP8Ltd81 X-Received: by 2002:a63:6a89:: with SMTP id f131-v6mr14896403pgc.165.1536076477024; Tue, 04 Sep 2018 08:54:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536076476; cv=none; d=google.com; s=arc-20160816; b=TLOT5QBC5yHiT7Pkrh4okdLeqhJ53QaTnfSXFwtJCyqIlD2b5udMDsQVJ8sF7Btugr xgs6KX79N41CcITG142/pKyHMThHp9ZoH+vsUluj8V2JCZtPq2O7WlGFFS7/WkcDHyVX qykCQYuKenc7Zmq8CIu46SKUX0nDFaw5m5yf1s0od6i2XJoWnOu+U4ArqHI1r53RQXjs Y+dscnmw6CmrkR/HnV6PGcnDXLX8ocI37nvm3dAmHXWSi0jWOHUFwkpk1RacfdJhkg/d AHsC/Vu5G3+QdWJ9dtY6nN5AGNLI5EI7DaCDXRPaDpFTdCnqaqGbQc7Tl8n1PMV4yr9R Np2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=ajyr3MuO21RHkZ2nu0kZrQDAbcKzDioaBFzdbbQnk08=; b=cPV/lYEFK62Gk3CP8cpYeeVwJTjxlDQ05X/7StnqChvYvv9JM1Qqr0cQEJSH4wIpr1 3FcKRRvNoA9FCubVs93SeRaLQ0ZCwnI+imT5g/rw6nKxMRUk/2X2VB1mWzEcpb4MRX76 kQPd8+e4Oja4R7ZEei9xb+v3Iit1zuwYhcsyyFqKN5FquwuqkMicR0L0M7Z7Sx4bnZR2 qLluqZxgJRyiyC0HSD5LwjpN6wioq/CwMfSbeLzbwg/xFgaui+Wavrxh65m7oigHQxkl 5m5S90JZysoBBs6wRc8OT08M7Y/+r0Pn3TZEinoKaUBRp5l2D/oZjW+Bh1xdXHAXkwjV HUdA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v3-v6si20811630plp.85.2018.09.04.08.54.22; Tue, 04 Sep 2018 08:54:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727628AbeIDUSf (ORCPT + 99 others); Tue, 4 Sep 2018 16:18:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38642 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727357AbeIDUSf (ORCPT ); Tue, 4 Sep 2018 16:18:35 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2005A8830B; Tue, 4 Sep 2018 15:52:53 +0000 (UTC) Received: from t450s.home (ovpn-116-77.phx2.redhat.com [10.3.116.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id D54EF19489; Tue, 4 Sep 2018 15:52:50 +0000 (UTC) Date: Tue, 4 Sep 2018 09:52:50 -0600 From: Alex Williamson To: Li Qiang Cc: eric.auger@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, liqiang02@corp.netease.com Subject: Re: [PATCH] vfio: fix potential memory leak in vfio_msi_cap_len Message-ID: <20180904095250.32e170c5@t450s.home> In-Reply-To: <1535374041-3551-1-git-send-email-liq3ea@gmail.com> References: <1535374041-3551-1-git-send-email-liq3ea@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 04 Sep 2018 15:52:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 27 Aug 2018 05:47:21 -0700 Li Qiang wrote: > Free the vdev->msi_perm in error path. > > Signed-off-by: Li Qiang > --- > drivers/vfio/pci/vfio_pci_config.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c > index 115a36f6f403..62023b4a373b 100644 > --- a/drivers/vfio/pci/vfio_pci_config.c > +++ b/drivers/vfio/pci/vfio_pci_config.c > @@ -1180,8 +1180,10 @@ static int vfio_msi_cap_len(struct vfio_pci_device *vdev, u8 pos) > return -ENOMEM; > > ret = init_pci_cap_msi_perm(vdev->msi_perm, len, flags); > - if (ret) > + if (ret) { > + kfree(vdev->msi_perm); > return ret; > + } > > return len; > } Fix looks correct to me, I'll queue this for v4.20 with Eric's R-b. Thanks, Alex