Skip to content

Commit 202c089

Browse files
jhovoldgregkh
authored andcommitted
firmware: sysfb: fix platform-device leak in error path
Make sure to free the platform device also in the unlikely event that registration fails. Fixes: 0589e88 ("drivers/firmware: Add missing platform_device_put() in sysfb_create_simplefb") Fixes: 8633ef8 ("drivers/firmware: consolidate EFI framebuffer setup for all arches") Cc: stable@vger.kernel.org # 5.14 Cc: Miaoqian Lin <linmq006@gmail.com> Cc: Javier Martinez Canillas <javierm@redhat.com> Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://lore.kernel.org/r/20220303180519.3117-1-johan@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b850b7a commit 202c089

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

drivers/firmware/sysfb_simplefb.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,21 @@ __init int sysfb_create_simplefb(const struct screen_info *si,
113113
sysfb_apply_efi_quirks(pd);
114114

115115
ret = platform_device_add_resources(pd, &res, 1);
116-
if (ret) {
117-
platform_device_put(pd);
118-
return ret;
119-
}
116+
if (ret)
117+
goto err_put_device;
120118

121119
ret = platform_device_add_data(pd, mode, sizeof(*mode));
122-
if (ret) {
123-
platform_device_put(pd);
124-
return ret;
125-
}
120+
if (ret)
121+
goto err_put_device;
122+
123+
ret = platform_device_add(pd);
124+
if (ret)
125+
goto err_put_device;
126+
127+
return 0;
128+
129+
err_put_device:
130+
platform_device_put(pd);
126131

127-
return platform_device_add(pd);
132+
return ret;
128133
}

0 commit comments

Comments
 (0)