Skip to content

Commit

Permalink
EDAC: Fix memleak in module init error path
Browse files Browse the repository at this point in the history
Make sure to use put_device() to free the initialised struct device so
that resources managed by driver core also gets released in the event of
a registration failure.

Signed-off-by: Johan Hovold <johan@kernel.org>
Cc: Denis Kirjanov <kirjanov@gmail.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-edac <linux-edac@vger.kernel.org>
Fixes: 2d56b10 ("EDAC: Handle error path in edac_mc_sysfs_init() properly")
Link: http://lkml.kernel.org/r/20180612124335.6420-1-johan@kernel.org
Signed-off-by: Borislav Petkov <bp@suse.de>
  • Loading branch information
Johan Hovold authored and Borislav Petkov committed Jun 17, 2018
1 parent 9d72fe1 commit 4708aa8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/edac/edac_mc_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1075,14 +1075,14 @@ int __init edac_mc_sysfs_init(void)

err = device_add(mci_pdev);
if (err < 0)
goto out_dev_free;
goto out_put_device;

edac_dbg(0, "device %s created\n", dev_name(mci_pdev));

return 0;

out_dev_free:
kfree(mci_pdev);
out_put_device:
put_device(mci_pdev);
out:
return err;
}
Expand Down

0 comments on commit 4708aa8

Please sign in to comment.