Skip to content

Commit a5a5470

Browse files
tdzgregkh
authored andcommitted
firmware: sysfb: Fix reference count of sysfb parent device
commit 3285d8f upstream. Retrieving the system framebuffer's parent device in sysfb_init() increments the parent device's reference count. Hence release the reference before leaving the init function. Adding the sysfb platform device acquires and additional reference for the parent. This keeps the parent device around while the system framebuffer is in use. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Fixes: 9eac534 ("firmware/sysfb: Set firmware-framebuffer parent device") Cc: Thomas Zimmermann <tzimmermann@suse.de> Cc: Javier Martinez Canillas <javierm@redhat.com> Cc: Helge Deller <deller@gmx.de> Cc: Jani Nikula <jani.nikula@intel.com> Cc: Dan Carpenter <dan.carpenter@linaro.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Sui Jingfeng <suijingfeng@loongson.cn> Cc: <stable@vger.kernel.org> # v6.9+ Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240625081818.15696-1-tzimmermann@suse.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8c4100b commit a5a5470

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

drivers/firmware/sysfb.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ static __init struct device *sysfb_parent_dev(const struct screen_info *si)
101101
if (IS_ERR(pdev)) {
102102
return ERR_CAST(pdev);
103103
} else if (pdev) {
104-
if (!sysfb_pci_dev_is_enabled(pdev))
104+
if (!sysfb_pci_dev_is_enabled(pdev)) {
105+
pci_dev_put(pdev);
105106
return ERR_PTR(-ENODEV);
107+
}
106108
return &pdev->dev;
107109
}
108110

@@ -137,7 +139,7 @@ static __init int sysfb_init(void)
137139
if (compatible) {
138140
pd = sysfb_create_simplefb(si, &mode, parent);
139141
if (!IS_ERR(pd))
140-
goto unlock_mutex;
142+
goto put_device;
141143
}
142144

143145
/* if the FB is incompatible, create a legacy framebuffer device */
@@ -155,7 +157,7 @@ static __init int sysfb_init(void)
155157
pd = platform_device_alloc(name, 0);
156158
if (!pd) {
157159
ret = -ENOMEM;
158-
goto unlock_mutex;
160+
goto put_device;
159161
}
160162

161163
pd->dev.parent = parent;
@@ -170,9 +172,11 @@ static __init int sysfb_init(void)
170172
if (ret)
171173
goto err;
172174

173-
goto unlock_mutex;
175+
goto put_device;
174176
err:
175177
platform_device_put(pd);
178+
put_device:
179+
put_device(parent);
176180
unlock_mutex:
177181
mutex_unlock(&disable_lock);
178182
return ret;

0 commit comments

Comments
 (0)