All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] driver: soc: xilinx: fix memory leak in xlnx_add_cb_for_notify_event()
@ 2022-11-29  1:01 Gaosheng Cui
  2022-11-30 17:06 ` Michal Simek
  2022-12-08 12:27 ` Michal Simek
  0 siblings, 2 replies; 3+ messages in thread
From: Gaosheng Cui @ 2022-11-29  1:01 UTC (permalink / raw)
  To: abhyuday.godhasara, michal.simek, gregkh, cuigaosheng1; +Cc: linux-arm-kernel

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>
---
 drivers/soc/xilinx/xlnx_event_manager.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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;
 
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] driver: soc: xilinx: fix memory leak in xlnx_add_cb_for_notify_event()
  2022-11-29  1:01 [PATCH] driver: soc: xilinx: fix memory leak in xlnx_add_cb_for_notify_event() Gaosheng Cui
@ 2022-11-30 17:06 ` Michal Simek
  2022-12-08 12:27 ` Michal Simek
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Simek @ 2022-11-30 17:06 UTC (permalink / raw)
  To: Gaosheng Cui, abhyuday.godhasara, michal.simek, gregkh; +Cc: linux-arm-kernel



On 11/29/22 02:01, Gaosheng Cui wrote:
> CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.
> 
> 
> 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>
> ---
>   drivers/soc/xilinx/xlnx_event_manager.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> 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;
> 
> --
> 2.25.1
> 

Acked-by: Michal Simek <michal.simek@amd.com>

Thanks,
Michal

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] driver: soc: xilinx: fix memory leak in xlnx_add_cb_for_notify_event()
  2022-11-29  1:01 [PATCH] driver: soc: xilinx: fix memory leak in xlnx_add_cb_for_notify_event() Gaosheng Cui
  2022-11-30 17:06 ` Michal Simek
@ 2022-12-08 12:27 ` Michal Simek
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Simek @ 2022-12-08 12:27 UTC (permalink / raw)
  To: Gaosheng Cui, abhyuday.godhasara, michal.simek, gregkh; +Cc: linux-arm-kernel



On 11/29/22 02:01, Gaosheng Cui wrote:
> 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>
> ---
>   drivers/soc/xilinx/xlnx_event_manager.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> 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;
> 
> --
> 2.25.1
> 

Applied.
M
-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP/Versal ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal/Versal NET SoCs


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-08 12:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29  1:01 [PATCH] driver: soc: xilinx: fix memory leak in xlnx_add_cb_for_notify_event() Gaosheng Cui
2022-11-30 17:06 ` Michal Simek
2022-12-08 12:27 ` Michal Simek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.