summaryrefslogtreecommitdiff
path: root/drivers/soc/xilinx
diff options
context:
space:
mode:
authorGaosheng Cui <cuigaosheng1@huawei.com>2022-11-29 04:01:46 +0300
committerMichal Simek <michal.simek@amd.com>2023-01-05 11:46:51 +0300
commit1bea534991b9b35c41848a397666ada436456beb (patch)
treecf2cdd5e27b5ee222f11650148917c9d16d8e7c9 /drivers/soc/xilinx
parent1b929c02afd37871d5afb9d498426f83432e71c2 (diff)
downloadlinux-1bea534991b9b35c41848a397666ada436456beb.tar.xz
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: 05e5ba40ea7a ("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>
Diffstat (limited to 'drivers/soc/xilinx')
-rw-r--r--drivers/soc/xilinx/xlnx_event_manager.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/soc/xilinx/xlnx_event_manager.c b/drivers/soc/xilinx/xlnx_event_manager.c
index 2de082765bef..c76381899ef4 100644
--- a/drivers/soc/xilinx/xlnx_event_manager.c
+++ b/drivers/soc/xilinx/xlnx_event_manager.c
@@ -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);
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;