From: Alex Deucher <alexdeucher@gmail.com> To: "Lazar, Lijo" <lijo.lazar@amd.com> Cc: Xinhui.Pan@amd.com, dri-devel@lists.freedesktop.org, christian.koenig@amd.com, amd-gfx@lists.freedesktop.org, yangyingliang@huawei.com, alexander.deucher@amd.com, Xiongfeng Wang <wangxiongfeng2@huawei.com>, Hawking.Zhang@amd.com Subject: Re: [PATCH 1/2] drm/radeon: Fix PCI device refcount leak in radeon_atrm_get_bios() Date: Tue, 22 Nov 2022 11:25:33 -0500 [thread overview] Message-ID: <CADnq5_M1GxWpRZYVkCUmFjFzG53hRe+-6d=MOEZ1hxJisx9DwQ@mail.gmail.com> (raw) In-Reply-To: <0167740e-7581-e85d-68f0-dc3e01d2a9a5@amd.com> On Tue, Nov 22, 2022 at 9:59 AM Lazar, Lijo <lijo.lazar@amd.com> wrote: > > > > On 11/22/2022 8:19 PM, Alex Deucher wrote: > > On Tue, Nov 22, 2022 at 6:12 AM Xiongfeng Wang > > <wangxiongfeng2@huawei.com> wrote: > >> > >> As comment of pci_get_class() says, it returns a pci_device with its > >> refcount increased and decreased the refcount for the input parameter > >> @from if it is not NULL. > >> > >> If we break the loop in radeon_atrm_get_bios() with 'pdev' not NULL, we > >> need to call pci_dev_put() to decrease the refcount. Add the missing > >> pci_dev_put() to avoid refcount leak. > > > > For both patches, I think pci_dev_put() needs to go into the loops. > > There are 2 or more GPUs on the systems where this is relevant. > > > > As per the logic, the loop breaks when it finds a valid ATRM handle. So > dev_put is required only for that device. Sure, but what if the handle is on the second DISPLAY_VGA or DISPLAY_OTHER class PCI device on the system? We've already called pci_get_class() for the first PCI device that matched. Alex > > When inside the loop this happens - "decreased the refcount for the > input parameter @from if it is not NULL" > > Thanks, > Lijo > > > Alex > > > >> > >> Fixes: d8ade3526b2a ("drm/radeon: handle non-VGA class pci devices with ATRM") > >> Fixes: c61e2775873f ("drm/radeon: split ATRM support out from the ATPX handler (v3)") > >> Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com> > >> --- > >> drivers/gpu/drm/radeon/radeon_bios.c | 1 + > >> 1 file changed, 1 insertion(+) > >> > >> diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c > >> index 33121655d50b..2df6ce3e32cb 100644 > >> --- a/drivers/gpu/drm/radeon/radeon_bios.c > >> +++ b/drivers/gpu/drm/radeon/radeon_bios.c > >> @@ -227,6 +227,7 @@ static bool radeon_atrm_get_bios(struct radeon_device *rdev) > >> > >> if (!found) > >> return false; > >> + pci_dev_put(pdev); > >> > >> rdev->bios = kmalloc(size, GFP_KERNEL); > >> if (!rdev->bios) { > >> -- > >> 2.20.1 > >>
WARNING: multiple messages have this Message-ID (diff)
From: Alex Deucher <alexdeucher@gmail.com> To: "Lazar, Lijo" <lijo.lazar@amd.com> Cc: Xinhui.Pan@amd.com, dri-devel@lists.freedesktop.org, christian.koenig@amd.com, amd-gfx@lists.freedesktop.org, daniel@ffwll.ch, yangyingliang@huawei.com, alexander.deucher@amd.com, airlied@gmail.com, Xiongfeng Wang <wangxiongfeng2@huawei.com>, Hawking.Zhang@amd.com Subject: Re: [PATCH 1/2] drm/radeon: Fix PCI device refcount leak in radeon_atrm_get_bios() Date: Tue, 22 Nov 2022 11:25:33 -0500 [thread overview] Message-ID: <CADnq5_M1GxWpRZYVkCUmFjFzG53hRe+-6d=MOEZ1hxJisx9DwQ@mail.gmail.com> (raw) In-Reply-To: <0167740e-7581-e85d-68f0-dc3e01d2a9a5@amd.com> On Tue, Nov 22, 2022 at 9:59 AM Lazar, Lijo <lijo.lazar@amd.com> wrote: > > > > On 11/22/2022 8:19 PM, Alex Deucher wrote: > > On Tue, Nov 22, 2022 at 6:12 AM Xiongfeng Wang > > <wangxiongfeng2@huawei.com> wrote: > >> > >> As comment of pci_get_class() says, it returns a pci_device with its > >> refcount increased and decreased the refcount for the input parameter > >> @from if it is not NULL. > >> > >> If we break the loop in radeon_atrm_get_bios() with 'pdev' not NULL, we > >> need to call pci_dev_put() to decrease the refcount. Add the missing > >> pci_dev_put() to avoid refcount leak. > > > > For both patches, I think pci_dev_put() needs to go into the loops. > > There are 2 or more GPUs on the systems where this is relevant. > > > > As per the logic, the loop breaks when it finds a valid ATRM handle. So > dev_put is required only for that device. Sure, but what if the handle is on the second DISPLAY_VGA or DISPLAY_OTHER class PCI device on the system? We've already called pci_get_class() for the first PCI device that matched. Alex > > When inside the loop this happens - "decreased the refcount for the > input parameter @from if it is not NULL" > > Thanks, > Lijo > > > Alex > > > >> > >> Fixes: d8ade3526b2a ("drm/radeon: handle non-VGA class pci devices with ATRM") > >> Fixes: c61e2775873f ("drm/radeon: split ATRM support out from the ATPX handler (v3)") > >> Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com> > >> --- > >> drivers/gpu/drm/radeon/radeon_bios.c | 1 + > >> 1 file changed, 1 insertion(+) > >> > >> diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c > >> index 33121655d50b..2df6ce3e32cb 100644 > >> --- a/drivers/gpu/drm/radeon/radeon_bios.c > >> +++ b/drivers/gpu/drm/radeon/radeon_bios.c > >> @@ -227,6 +227,7 @@ static bool radeon_atrm_get_bios(struct radeon_device *rdev) > >> > >> if (!found) > >> return false; > >> + pci_dev_put(pdev); > >> > >> rdev->bios = kmalloc(size, GFP_KERNEL); > >> if (!rdev->bios) { > >> -- > >> 2.20.1 > >>
next prev parent reply other threads:[~2022-11-22 16:25 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-22 11:30 [PATCH 0/2] drm: Fix PCI device refcount leak Xiongfeng Wang 2022-11-22 11:30 ` [PATCH 1/2] drm/radeon: Fix PCI device refcount leak in radeon_atrm_get_bios() Xiongfeng Wang 2022-11-22 14:49 ` Alex Deucher 2022-11-22 14:49 ` Alex Deucher 2022-11-22 14:59 ` Lazar, Lijo 2022-11-22 14:59 ` Lazar, Lijo 2022-11-22 16:25 ` Alex Deucher [this message] 2022-11-22 16:25 ` Alex Deucher 2022-11-22 17:10 ` Lazar, Lijo 2022-11-22 17:10 ` Lazar, Lijo 2022-11-22 17:13 ` Alex Deucher 2022-11-22 17:13 ` Alex Deucher 2022-11-22 11:30 ` [PATCH 2/2] drm/amdgpu: Fix PCI device refcount leak in amdgpu_atrm_get_bios() Xiongfeng Wang 2022-11-25 18:37 ` Alex Deucher 2022-11-25 18:37 ` Alex Deucher
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='CADnq5_M1GxWpRZYVkCUmFjFzG53hRe+-6d=MOEZ1hxJisx9DwQ@mail.gmail.com' \ --to=alexdeucher@gmail.com \ --cc=Hawking.Zhang@amd.com \ --cc=Xinhui.Pan@amd.com \ --cc=alexander.deucher@amd.com \ --cc=amd-gfx@lists.freedesktop.org \ --cc=christian.koenig@amd.com \ --cc=dri-devel@lists.freedesktop.org \ --cc=lijo.lazar@amd.com \ --cc=wangxiongfeng2@huawei.com \ --cc=yangyingliang@huawei.com \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.