Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1810210imm; Mon, 3 Sep 2018 10:01:55 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZFYN60hKjPvRAjuIXbcxFvG7oPguoJ7kilhhu+emJoVrk/YCcwrGuYQCRoo/Q0sPUOBn5H X-Received: by 2002:a17:902:8541:: with SMTP id d1-v6mr29736661plo.81.1535994115303; Mon, 03 Sep 2018 10:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535994115; cv=none; d=google.com; s=arc-20160816; b=Z28wPZd2lyUPUQMwn9pghriHH5/GQ+FWNzUH2PPSA+VPDt+tNYtVreYP1YKuMhIfY0 JVb1q7fZMqIA/D3Vyzzc65NnPy28Is3AurfwS46ZiJAetk9IZO50+7szDZWUtOOP7Y+z UmVoUgy7QX5MjJCTVbZkgbe5DEXoeQk7LlyD/r7A6qmHs9m/pr02K+450mTnTyOSzmgk DKcJtmqOgFL7n2+zeX+vVYTh4V1W1GSZ7HvS5+kpiivjTY8uo3Diob9YghDYdYJOaq16 QRHZ48boggzUcwTFtEIps2ijBdkGFlpmaTGMSfimcpHC/dz6dyRWEx+6bv54G/qsgQpD Wv/Q== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=ToZw0mLlqrY4OIdq24fukJH1av3fQLgOnVbEsRCIDkA=; b=JZmwVIH9jU39gPvyuZMtyn9GZIuEUqXDBH5pudYqVJi6WkMpMGyTSbrMYTdkahFJhx m5ueAPQVzLjrU0Kjh/8RXj0mBCCBgl7Xtrm4wb+j3wcZe+GX600dmEN/kDkellYS0cmc 0K4AxHFiOXF/silgw+HyqNYUdfoRNxEYu3wl1iicxbeDA0Bp97qw30Is01yNXiTxN4NQ p9+V6uYsEVeseJXWPwQjlowXr9SZmsZeDzpfgDf0jerkV2VHDPSy5gqSugQ/Y4y+SxBR 4JII5NGoxOtPasXtnoEqkx2qpgVJ1BsKyjbmvbkEAx6xfhiHbTTbojQxJUoWUoZ+5SJi 7uAQ== 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 3-v6si19602319plu.65.2018.09.03.10.01.39; Mon, 03 Sep 2018 10:01:55 -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 S1728162AbeICVVX (ORCPT + 99 others); Mon, 3 Sep 2018 17:21:23 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42270 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727762AbeICVVX (ORCPT ); Mon, 3 Sep 2018 17:21:23 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0C0CC40241C6; Mon, 3 Sep 2018 17:00:24 +0000 (UTC) Received: from [10.36.116.60] (ovpn-116-60.ams2.redhat.com [10.36.116.60]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1672B100F350; Mon, 3 Sep 2018 17:00:18 +0000 (UTC) Subject: Re: [PATCH] vfio: fix potential memory leak in vfio_msi_cap_len To: David Hildenbrand , Li Qiang , alex.williamson@redhat.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, liqiang02@corp.netease.com References: <1535374041-3551-1-git-send-email-liq3ea@gmail.com> From: Auger Eric Message-ID: Date: Mon, 3 Sep 2018 19:00:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 03 Sep 2018 17:00:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 03 Sep 2018 17:00:24 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Li, David, On 08/30/2018 04:15 PM, David Hildenbrand wrote: > On 27.08.2018 14:47, 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; >> } >> > > Doesn't vfio_config_free() take care of that in all cases? Looks OK to me. Reviewed-by: Eric Auger Looks vfio_config_free is called on vfio_pci_release whereas vfio_msi_cap_len can fail in vfio_pci_open path. Thanks Eric >