drivers: soc: xilinx: add the missing kfree in xlnx_add_cb_for_suspend()
[ Upstream commit44ed4f90a9] If we fail to allocate memory for cb_data by kmalloc, the memory allocation for eve_data is never freed, add the missing kfree() in the error handling path. Fixes:05e5ba40ea("driver: soc: xilinx: Add support of multiple callbacks for same event in event management driver") Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com> Link: https://lore.kernel.org/r/20240706065155.452764-1-cuigaosheng1@huawei.com Signed-off-by: Michal Simek <michal.simek@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
d3a5e7ffbd
commit
882d7afaa4
@@ -174,8 +174,10 @@ static int xlnx_add_cb_for_suspend(event_cb_func_t cb_fun, void *data)
|
||||
INIT_LIST_HEAD(&eve_data->cb_list_head);
|
||||
|
||||
cb_data = kmalloc(sizeof(*cb_data), GFP_KERNEL);
|
||||
if (!cb_data)
|
||||
if (!cb_data) {
|
||||
kfree(eve_data);
|
||||
return -ENOMEM;
|
||||
}
|
||||
cb_data->eve_cb = cb_fun;
|
||||
cb_data->agent_data = data;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user