Skip to content

Commit 3285d8f

Browse files
author
Thomas Zimmermann
committed
firmware: sysfb: Fix reference count of sysfb parent device
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 <[email protected]> Fixes: 9eac534 ("firmware/sysfb: Set firmware-framebuffer parent device") Cc: Thomas Zimmermann <[email protected]> Cc: Javier Martinez Canillas <[email protected]> Cc: Helge Deller <[email protected]> Cc: Jani Nikula <[email protected]> Cc: Dan Carpenter <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Sui Jingfeng <[email protected]> Cc: <[email protected]> # v6.9+ Reviewed-by: Javier Martinez Canillas <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 66edf3f commit 3285d8f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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)