From: Sasha Levin <sashal@kernel.org>
To: Dexuan Cui <decui@microsoft.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"lorenzo.pieralisi@arm.com" <lorenzo.pieralisi@arm.com>,
Michael Kelley <mikelley@microsoft.com>,
"stephen@networkplumber.org" <stephen@networkplumber.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: FAILED: patch "[PATCH] PCI: hv: Fix a memory leak in hv_eject_device_work()" failed to apply to 4.9-stable tree
Date: Thu, 16 May 2019 20:43:01 -0400 [thread overview]
Message-ID: <20190517004301.GW11972@sasha-vm> (raw)
In-Reply-To: <PU1P153MB0169E1485667016EAE6EDB84BF090@PU1P153MB0169.APCP153.PROD.OUTLOOK.COM>
On Wed, May 15, 2019 at 11:14:31PM +0000, Dexuan Cui wrote:
>> From: gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>
>> Sent: Wednesday, May 15, 2019 1:35 AM
>> To: Dexuan Cui <decui@microsoft.com>; lorenzo.pieralisi@arm.com; Michael
>> Kelley <mikelley@microsoft.com>; stephen@networkplumber.org
>> Cc: stable@vger.kernel.org
>> Subject: FAILED: patch "[PATCH] PCI: hv: Fix a memory leak in
>> hv_eject_device_work()" failed to apply to 4.9-stable tree
>>
>>
>> The patch below does not apply to the 4.9-stable tree.
>> If someone wants it applied there, or to any other stable or longterm
>> tree, then please email the backport, including the original git commit
>> id to <stable@vger.kernel.org>.
>>
>> thanks,
>>
>> greg k-h
>>
>> ------------------ original commit in Linus's tree ------------------
>>
>> From 05f151a73ec2b23ffbff706e5203e729a995cdc2 Mon Sep 17 00:00:00
>> 2001
>> From: Dexuan Cui <decui@microsoft.com>
>> Date: Mon, 4 Mar 2019 21:34:48 +0000
>> Subject: [PATCH] PCI: hv: Fix a memory leak in hv_eject_device_work()
>>
>> When a device is created in new_pcichild_device(), hpdev->refs is set
>> to 2 (i.e. the initial value of 1 plus the get_pcichild()).
>>
>> When we hot remove the device from the host, in a Linux VM we first call
>> hv_pci_eject_device(), which increases hpdev->refs by get_pcichild() and
>> then schedules a work of hv_eject_device_work(), so hpdev->refs becomes
>> 3 (let's ignore the paired get/put_pcichild() in other places). But in
>> hv_eject_device_work(), currently we only call put_pcichild() twice,
>> meaning the 'hpdev' struct can't be freed in put_pcichild().
>>
>> Add one put_pcichild() to fix the memory leak.
>>
>> The device can also be removed when we run "rmmod pci-hyperv". On this
>> path (hv_pci_remove() -> hv_pci_bus_exit() -> hv_pci_devices_present()),
>> hpdev->refs is 2, and we do correctly call put_pcichild() twice in
>> pci_devices_present_work().
>>
>> Fixes: 4daace0d8ce8 ("PCI: hv: Add paravirtual PCI front-end for Microsoft
>> Hyper-V VMs")
>> Signed-off-by: Dexuan Cui <decui@microsoft.com>
>> [lorenzo.pieralisi@arm.com: commit log rework]
>> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
>> Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
>> Reviewed-by: Michael Kelley <mikelley@microsoft.com>
>> Cc: stable@vger.kernel.org
>>
>> diff --git a/drivers/pci/controller/pci-hyperv.c
>> b/drivers/pci/controller/pci-hyperv.c
>> index 95441a35eceb..30f16b882746 100644
>> --- a/drivers/pci/controller/pci-hyperv.c
>> +++ b/drivers/pci/controller/pci-hyperv.c
>> @@ -1900,6 +1900,9 @@ static void hv_eject_device_work(struct work_struct
>> *work)
>> sizeof(*ejct_pkt), (unsigned long)&ctxt.pkt,
>> VM_PKT_DATA_INBAND, 0);
>>
>> + /* For the get_pcichild() in hv_pci_eject_device() */
>> + put_pcichild(hpdev);
>> + /* For the two refs got in new_pcichild_device() */
>> put_pcichild(hpdev);
>> put_pcichild(hpdev);
>> put_hvpcibus(hpdev->hbus);
>
>Hi,
>I backported the patch for linux-4.9.y. Please use the attached patch.
>
>Thanks,
>-- Dexuan
Queued for 4.9, thanks.
--
Thanks,
Sasha
prev parent reply other threads:[~2019-05-17 0:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-15 8:34 FAILED: patch "[PATCH] PCI: hv: Fix a memory leak in hv_eject_device_work()" failed to apply to 4.9-stable tree gregkh
2019-05-15 23:14 ` Dexuan Cui
2019-05-17 0:43 ` Sasha Levin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190517004301.GW11972@sasha-vm \
--to=sashal@kernel.org \
--cc=decui@microsoft.com \
--cc=gregkh@linuxfoundation.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=mikelley@microsoft.com \
--cc=stable@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox