diff options
author | Guenter Roeck <linux@roeck-us.net> | 2017-11-15 16:00:44 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-11-28 10:57:18 -0500 |
commit | e4b28b3c3a405b251fa25db58abe1512814a680a (patch) | |
tree | b7461c665352eb2c47c68eabe431e78a7613cb00 /drivers/firmware/google | |
parent | 811d7e0215fb738fb9a9f0bcb1276516ad161ed1 (diff) |
firmware: vpd: Tie firmware kobject to device lifetime
It doesn't make sense to have /sys/firmware/vpd if the device is not
instantiated, so tie its lifetime to the device.
Fixes: 049a59db34eb ("firmware: Google VPD sysfs driver")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Cc: stable <stable@vger.kernel.org>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/firmware/google')
-rw-r--r-- | drivers/firmware/google/vpd.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c index 84217172297b..942e358efa60 100644 --- a/drivers/firmware/google/vpd.c +++ b/drivers/firmware/google/vpd.c | |||
@@ -295,7 +295,17 @@ static int vpd_probe(struct platform_device *pdev) | |||
295 | if (ret) | 295 | if (ret) |
296 | return ret; | 296 | return ret; |
297 | 297 | ||
298 | return vpd_sections_init(entry.cbmem_addr); | 298 | vpd_kobj = kobject_create_and_add("vpd", firmware_kobj); |
299 | if (!vpd_kobj) | ||
300 | return -ENOMEM; | ||
301 | |||
302 | ret = vpd_sections_init(entry.cbmem_addr); | ||
303 | if (ret) { | ||
304 | kobject_put(vpd_kobj); | ||
305 | return ret; | ||
306 | } | ||
307 | |||
308 | return 0; | ||
299 | } | 309 | } |
300 | 310 | ||
301 | static int vpd_remove(struct platform_device *pdev) | 311 | static int vpd_remove(struct platform_device *pdev) |
@@ -303,6 +313,8 @@ static int vpd_remove(struct platform_device *pdev) | |||
303 | vpd_section_destroy(&ro_vpd); | 313 | vpd_section_destroy(&ro_vpd); |
304 | vpd_section_destroy(&rw_vpd); | 314 | vpd_section_destroy(&rw_vpd); |
305 | 315 | ||
316 | kobject_put(vpd_kobj); | ||
317 | |||
306 | return 0; | 318 | return 0; |
307 | } | 319 | } |
308 | 320 | ||
@@ -322,10 +334,6 @@ static int __init vpd_platform_init(void) | |||
322 | if (IS_ERR(pdev)) | 334 | if (IS_ERR(pdev)) |
323 | return PTR_ERR(pdev); | 335 | return PTR_ERR(pdev); |
324 | 336 | ||
325 | vpd_kobj = kobject_create_and_add("vpd", firmware_kobj); | ||
326 | if (!vpd_kobj) | ||
327 | return -ENOMEM; | ||
328 | |||
329 | platform_driver_register(&vpd_driver); | 337 | platform_driver_register(&vpd_driver); |
330 | 338 | ||
331 | return 0; | 339 | return 0; |
@@ -333,7 +341,6 @@ static int __init vpd_platform_init(void) | |||
333 | 341 | ||
334 | static void __exit vpd_platform_exit(void) | 342 | static void __exit vpd_platform_exit(void) |
335 | { | 343 | { |
336 | kobject_put(vpd_kobj); | ||
337 | } | 344 | } |
338 | 345 | ||
339 | module_init(vpd_platform_init); | 346 | module_init(vpd_platform_init); |