Fixes for v4.19-rc7
- Fix failure-path memory leak in ramoops_init (nixiaoming) -----BEGIN PGP SIGNATURE----- Comment: Kees Cook <kees@outflux.net> iQJKBAABCgA0FiEEpcP2jyKd1g9yPm4TiXL039xtwCYFAluxB3cWHGtlZXNjb29r QGNocm9taXVtLm9yZwAKCRCJcvTf3G3AJidvEACZlqemGsSVQ4elXWCW9EPqyVSn lbPg5ONurG/51J6313Ankgn7PrOI7WRd3iAXUWYByoc0DXn/jgz0i/B1+MtSnH4g fMeZ3DMnwmuC4h8/50/xmxbjKj2+vW7tX+978wWbYnvYNC+UXf8CN4J4MwBFmNR3 DGH+oVCx2MITbIYQ3u5FIUgRJl0sD15GtxHg/l5Ff78dtUJVvlnD6ZAa9/rDBCPu DD0IqjJ5BqTmGw98L2tG0I2SDSrC8TGAYdQlZK/k7vHUqCWP6QspCpQQy3x6bh+W QRL6gCNEPZIGB+uAVbueCo80zRrx1NltbkbO4n9zn9ItYxpvOXJwGT4peYYXwabO nn+cWwRAJGITp9BFKIk/V8p05rpRhw8oeOBHIzwylb3C6bqK3ijnkk9mNSmUnLPG FtzRs/cYEMHi7n7+aygm1lNHn98PAWGLmomXLyxIUtsSH1jvFWG+jxLiRih/Oah5 qjSGw2r681vLKsj2tQV4hpFvWaV83t2cO1QOldWSSkVHKJO9+pglEUGz9gfCvBRz bCvA0aPNGmMGTO0faQMB/TG2pMtOK94UU6kBIALxlEeHrtdpoOaQN6g++R7sY3/y SWo8BeGlNMSAtkWtd6Y7xxIF5N4PDDc6iMyjHGM/KCptANVu03BWlfOn32tel9jR 17wiJi6SjqQjHVp7jw== =bzfz -----END PGP SIGNATURE----- Merge tag 'pstore-v4.19-rc7' of https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux Kees writes: "Pstore fixes for v4.19-rc7 - Fix failure-path memory leak in ramoops_init (nixiaoming)" * tag 'pstore-v4.19-rc7' of https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: pstore/ram: Fix failure-path memory leak in ramoops_init
This commit is contained in:
Коммит
ef0f2584c2
|
@ -898,8 +898,22 @@ static struct platform_driver ramoops_driver = {
|
|||
},
|
||||
};
|
||||
|
||||
static void ramoops_register_dummy(void)
|
||||
static inline void ramoops_unregister_dummy(void)
|
||||
{
|
||||
platform_device_unregister(dummy);
|
||||
dummy = NULL;
|
||||
|
||||
kfree(dummy_data);
|
||||
dummy_data = NULL;
|
||||
}
|
||||
|
||||
static void __init ramoops_register_dummy(void)
|
||||
{
|
||||
/*
|
||||
* Prepare a dummy platform data structure to carry the module
|
||||
* parameters. If mem_size isn't set, then there are no module
|
||||
* parameters, and we can skip this.
|
||||
*/
|
||||
if (!mem_size)
|
||||
return;
|
||||
|
||||
|
@ -932,21 +946,28 @@ static void ramoops_register_dummy(void)
|
|||
if (IS_ERR(dummy)) {
|
||||
pr_info("could not create platform device: %ld\n",
|
||||
PTR_ERR(dummy));
|
||||
dummy = NULL;
|
||||
ramoops_unregister_dummy();
|
||||
}
|
||||
}
|
||||
|
||||
static int __init ramoops_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ramoops_register_dummy();
|
||||
return platform_driver_register(&ramoops_driver);
|
||||
ret = platform_driver_register(&ramoops_driver);
|
||||
if (ret != 0)
|
||||
ramoops_unregister_dummy();
|
||||
|
||||
return ret;
|
||||
}
|
||||
late_initcall(ramoops_init);
|
||||
|
||||
static void __exit ramoops_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&ramoops_driver);
|
||||
platform_device_unregister(dummy);
|
||||
kfree(dummy_data);
|
||||
ramoops_unregister_dummy();
|
||||
}
|
||||
module_exit(ramoops_exit);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче