driver: soc: xilinx: fix memory leak in xlnx_add_cb_for_notify_event()
The kfree() should be called when memory fails to be allocated for
cb_data in xlnx_add_cb_for_notify_event(), otherwise there will be
a memory leak, so add kfree() to fix it.
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>
Acked-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/20221129010146.1026685-1-cuigaosheng1@huawei.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
This commit is contained in:
parent
1b929c02af
commit
1bea534991
|
@ -116,8 +116,10 @@ static int xlnx_add_cb_for_notify_event(const u32 node_id, const u32 event, cons
|
||||||
INIT_LIST_HEAD(&eve_data->cb_list_head);
|
INIT_LIST_HEAD(&eve_data->cb_list_head);
|
||||||
|
|
||||||
cb_data = kmalloc(sizeof(*cb_data), GFP_KERNEL);
|
cb_data = kmalloc(sizeof(*cb_data), GFP_KERNEL);
|
||||||
if (!cb_data)
|
if (!cb_data) {
|
||||||
|
kfree(eve_data);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
cb_data->eve_cb = cb_fun;
|
cb_data->eve_cb = cb_fun;
|
||||||
cb_data->agent_data = data;
|
cb_data->agent_data = data;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue