Skip to content

Commit

Permalink
dmi-id: don't free dev structure after calling device_register
Browse files Browse the repository at this point in the history
dmi_dev is freed in error exit code but, according to the document
of device_register, it should never directly free device structure
after calling this function, even if it returned an error! Use
put_device() instead.

Signed-off-by: Allen Hung <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
  • Loading branch information
allenhung8 authored and jdelvare committed Sep 8, 2016
1 parent d71f058 commit 9b41b92
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/firmware/dmi-id.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,14 @@ static int __init dmi_id_init(void)

ret = device_register(dmi_dev);
if (ret)
goto fail_free_dmi_dev;
goto fail_put_dmi_dev;

return 0;

fail_free_dmi_dev:
kfree(dmi_dev);
fail_class_unregister:
fail_put_dmi_dev:
put_device(dmi_dev);

fail_class_unregister:
class_unregister(&dmi_class);

return ret;
Expand Down

0 comments on commit 9b41b92

Please sign in to comment.