Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5863971imm; Mon, 27 Aug 2018 05:48:55 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbFpjQB9Wq7E6ylfeGJwObWyZ8l71Kc9619oVEQe8/rAJ5vbKVl7xN1KfbCl5FOcQG+gRIT X-Received: by 2002:a63:a745:: with SMTP id w5-v6mr12047376pgo.374.1535374135373; Mon, 27 Aug 2018 05:48:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535374135; cv=none; d=google.com; s=arc-20160816; b=EOEIKBUUCZwY2z9LH8iQfYZhiW814SesyI54FRVr8/XXZ5gdzwiPVfJmEO8Jrz7Kpz RZtlag5fR1PgqrNnWQza9JEfK2/uzr62a4eroawq4fMn+aAOYVoTtaGSKZRtO31R5LOe KaIMekeWE+4mnTB/TJdTr9p2etGg5h17yAIKWOkwhHodofxy9qV/OyS+cIr2PshKp8dR 5saT1IfuEcNxzizpoGAKclEa4pHCBpvwaYCp66YkQi3vWnAzuXyJU6peZqRBQtucHCRW EVAIa24g5XEQfUFcjmt1FXLKkgMs5XQgqSyhcjeut8pkEKdSQ4r5IWLsPLEU467N90lp tQSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=CWQdb4PUOssyyJvHBQOSqSYqNSh0j6gj8Aqj/gw0/20=; b=ptfDmKVzfZZTAOr7vkBRAZMfi9cXU+CqlF1hKwq0uDlW3KF0LHO14Urq8F6yM0lkia uRumwp+n6ZUX2+StxnGwCYED/Jdi2hj44iqPV+DNXUBqhtfDuq57cITOdteUZ09iwozk ZyIHydOBaAxNUOhTQ1dSJSuYTqtIkLkGI2EVWUx330oU9uCFMTIhqnpcjjN53SPEsxEj /UE2jUZIQXuV5h004rUbMWIUVZdL1BR8ap6Q0P5E9R+X9LYYF/gnz8+TaWsCYSDEPiJr TczJYkbi6KyFUhkTk7AGZuX2/EVxd7itYKzOcEIChooOFmY10N9D6/rTy6aVfGzxveoi FDyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iO4QD1Ib; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h69-v6si13387548pge.13.2018.08.27.05.48.37; Mon, 27 Aug 2018 05:48: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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iO4QD1Ib; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727255AbeH0Qd7 (ORCPT + 99 others); Mon, 27 Aug 2018 12:33:59 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:39748 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726809AbeH0Qd7 (ORCPT ); Mon, 27 Aug 2018 12:33:59 -0400 Received: by mail-pf1-f196.google.com with SMTP id j8-v6so7704383pff.6; Mon, 27 Aug 2018 05:47:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=CWQdb4PUOssyyJvHBQOSqSYqNSh0j6gj8Aqj/gw0/20=; b=iO4QD1Ibko0bBz6aI3lmWYQs41k7EWHctARh09BUnCYjGBDWPJjxDYmhPaNeVQAYGT MpvJEQt1sQGftvmnyybJp84SdBOo85BAYBjBUbvGWxX28jl1bMtWFXXbju0afxxzcadp OKS/CGYqx+U1GD05zJ7YjXeByT8JkvxZKCnnQMhNaoU+emqk9dEx4fFGzhM/Y82yihbY WBDb+Agf2dN/gAvwBmltW5PfI83JgxulL+fjCYhUlgmy/XBVRyxgJAODyVZS3pM7YAtX 84uTVA8lffJAZKsK6b5551bN8v0TqOF9oVluPVroAbnDcy3SN/3/xLU2VsgnOzu1YLbi sSKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=CWQdb4PUOssyyJvHBQOSqSYqNSh0j6gj8Aqj/gw0/20=; b=eAZ7K2CLizrWYhlM9ilmN/HUZjfnX0dtZTz4lb38kFi/0qDNqhbMkqwfPz/f63YfAb h43jiKbWTrCnzN5dkum7qr1k/Cvbl5hDRQqMANGGqCCCWADfGOYLPh3blIBwSWQM+uzh hXaecrr5XD+bm4Jqvb/Sib9IK5aepkl/uYBM/Sues5AACDDAjUO8122n1VRT7eQmwA5e yTNogsHHbPGiTTDgaA2ijbDt0otlyhIv4kJ1kdhulRGtLeDrIi7/AnM4Jle41idu/ZHB KRlPkfAl7RqsRIIwaz9WPC+R2YXk8VepWcIRGGgZN1hlrVUQKMKorf97vQ2nCxJ7kl4r NR4Q== X-Gm-Message-State: APzg51Di9Z4em+k6j1eP2KvnHL7nKcUltNFhgBBSRl4s6vEnDDkduODc jUqkVSeuLCH+Gpq8ZJzzgcg= X-Received: by 2002:a63:6054:: with SMTP id u81-v6mr12398606pgb.433.1535374048681; Mon, 27 Aug 2018 05:47:28 -0700 (PDT) Received: from localhost.localdomain.localdomain ([103.65.40.43]) by smtp.gmail.com with ESMTPSA id z6-v6sm19942639pgr.41.2018.08.27.05.47.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 05:47:28 -0700 (PDT) From: Li Qiang To: alex.williamson@redhat.com, eric.auger@redhat.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, liqiang02@corp.netease.com, Li Qiang Subject: [PATCH] vfio: fix potential memory leak in vfio_msi_cap_len Date: Mon, 27 Aug 2018 05:47:21 -0700 Message-Id: <1535374041-3551-1-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 2.11.0