Commit 74d3a33f authored by Russell King (Oracle)'s avatar Russell King (Oracle) Committed by zhaoxiaoqiang11
Browse files

nvmem: core: initialise nvmem->id early

stable inclusion
from stable-v5.10.168
commit bb875f0a34e775500f74bfaedf72e049733d9211
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7URR4

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=bb875f0a34e775500f74bfaedf72e049733d9211



----------------------------------------------------

commit 3bd747c7 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: f7d8d7dc ("nvmem: fix memory leak in error path")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230127104015.23839-4-srinivas.kandagatla@linaro.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarzhaoxiaoqiang11 <zhaoxiaoqiang11@jd.com>
parent 5fcab7cb
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment