]> git.baikalelectronics.ru Git - kernel.git/commit
nvmem: core: initialise nvmem->id early
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Fri, 27 Jan 2023 10:40:08 +0000 (10:40 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Feb 2023 10:28:24 +0000 (11:28 +0100)
commit9feae5d294957238da9576599cc3c7a4deb266df
treef6a7a5ff4eee5d40927f7e9e8b8ed48be9084f40
parent29eaa306fc0b97e41efd5d736bdc917e73fa91b7
nvmem: core: initialise nvmem->id early

commit 3bd747c7ea13cb145f0d84444e00df928b0842d9 upstream.

The error path for wp_gpio attempts to free the IDA nvmem->id, but
this has yet to be assigned, so will always be zero - leaking the
ID allocated by ida_alloc(). Fix this by moving the initialisation
of nvmem->id earlier.

Fixes: b830dbc0823f ("nvmem: fix memory leak in error path")
Cc: stable@vger.kernel.org
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230127104015.23839-4-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvmem/core.c