Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1948366ybv; Fri, 14 Feb 2020 08:42:50 -0800 (PST) X-Google-Smtp-Source: APXvYqwBA8zAn4OPubqL/rhUR5raMvXgHanLwtBG3jXHz8SZjkz3fyBVbb7qBwF+FXRwCulM0TTf X-Received: by 2002:a9d:750b:: with SMTP id r11mr3149101otk.310.1581698569889; Fri, 14 Feb 2020 08:42:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581698569; cv=none; d=google.com; s=arc-20160816; b=yY0/O6Jbgb3C+Htn5sOR7ZLCbpulF28ZYQGc9CV33aSFsqhUDGXr/eP+pKRrKNRKkZ VsfTFOTJ1dJgQzYBPI3hYrxFZxB6oxVUV384YfTHbMsztgh+hHuqopEcUcOtKSpHpER8 i0FXM6NYesguDp9WMXs7Y1yOVKZUO6VOEC1Y1uuGapKX0St6+B5cWwK/3tVLucHyjBvt Iy7KAwp5SNkxGbnFyuQ/FUsWgVdAwupPS9aR53KPXdWfaauyqLH4DTITnlcsQZK/LAFz pBgwR5GMyWZGIAVP715jEQ8hVGIk/YZjW/QNy1/mdw1TOzady0FCD7cRtCXTWpwBVmfS p/mw== 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:date:subject:cc:to:from :dkim-signature; bh=I7HJ6KgisLWo9nNJ+hQzJeacHB0T2WXfWUkySXNLGXY=; b=IOX0PZIeyuckeFemW1seLxN3/ot2+UVqtWlrWDL0+bBdLCyMFBX8ht8qobrpa6EVUL 6rtXht6ylHx6antyFKiPbmmxHIzBfqQOlGCswoU5o20/gx87BZ1wlAUKBjelZFavbgus HuM42AyzNh+ukhknppINo9xm5Y+gWajcP5H958DOZRp4291Fupe6MKoUchD0dNojPLCJ sVVKTViCRV8y7xOG3S1zEu+HWMjyOpHj+yLMniRJd55RfIuH2v8ZopIKl1bLHm8JlhMp HwVeSWFr650xgWpzimwVOXPsLhAhjep09uiTzMa8M2nBRs0nsQO4Vo33Akj9YbPQ1Q7l H+qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sv83o8K6; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s17si3058966otr.320.2020.02.14.08.42.38; Fri, 14 Feb 2020 08:42:49 -0800 (PST) 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=@kernel.org header.s=default header.b=sv83o8K6; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393906AbgBNQl7 (ORCPT + 99 others); Fri, 14 Feb 2020 11:41:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:57952 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405236AbgBNQW0 (ORCPT ); Fri, 14 Feb 2020 11:22:26 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 449F82474F; Fri, 14 Feb 2020 16:22:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697346; bh=l92YRp2hrO486tqbN8RnprRK8i7utwrkSIwetpc6F7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sv83o8K6gwNQV2dDQhge60SOEiYtD5Ke235EZ2m3fILikkypRVBspJDenPRzOTPsE N5bMvntdNo+8ZJeVkhqmz0lYn8z1ypxlqFZi/Y9LpG+ljp+tY/59svSKhErf/d4pW4 j5xoHOLtZDOqscV885405t78IBMZZ1mHuc9QLNUg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Navid Emamdoost , Bjorn Helgaas , Sasha Levin , linux-pci@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 050/141] PCI/IOV: Fix memory leak in pci_iov_add_virtfn() Date: Fri, 14 Feb 2020 11:19:50 -0500 Message-Id: <20200214162122.19794-50-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214162122.19794-1-sashal@kernel.org> References: <20200214162122.19794-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Navid Emamdoost [ Upstream commit 8c386cc817878588195dde38e919aa6ba9409d58 ] In the implementation of pci_iov_add_virtfn() the allocated virtfn is leaked if pci_setup_device() fails. The error handling is not calling pci_stop_and_remove_bus_device(). Change the goto label to failed2. Fixes: 156c55325d30 ("PCI: Check for pci_setup_device() failure in pci_iov_add_virtfn()") Link: https://lore.kernel.org/r/20191125195255.23740-1-navid.emamdoost@gmail.com Signed-off-by: Navid Emamdoost Signed-off-by: Bjorn Helgaas Signed-off-by: Sasha Levin --- drivers/pci/iov.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 1d32fe2d97aa7..9ec3cb628b0b6 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -181,6 +181,7 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id, int reset) failed2: sysfs_remove_link(&dev->dev.kobj, buf); failed1: + pci_stop_and_remove_bus_device(virtfn); pci_dev_put(dev); mutex_lock(&iov->dev->sriov->lock); pci_stop_and_remove_bus_device(virtfn); -- 2.20.1