netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] dpll: Fix potential msg memleak when genlmsg_put_reply failed
       [not found] <0c6e0cd5-d975-41cc-824e-10b5e28251a2@linux.dev>
@ 2023-11-21  1:37 ` Hao Ge
  2023-11-21 11:20   ` Vadim Fedorenko
  2023-11-22  1:50   ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Hao Ge @ 2023-11-21  1:37 UTC (permalink / raw)
  To: vadim.fedorenko, arkadiusz.kubalewski
  Cc: jiri, michal.michalik, davem, linux-kernel, netdev, Hao Ge

We should clean the skb resource if genlmsg_put_reply failed.

Fixes: 9d71b54b65b1 ("dpll: netlink: Add DPLL framework base functions")
Signed-off-by: Hao Ge <gehao@kylinos.cn>
---
v1 -> v2: change title due to add some similar fix for some similar cases
---
 drivers/dpll/dpll_netlink.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
index a6dc3997bf5c..442a0ebeb953 100644
--- a/drivers/dpll/dpll_netlink.c
+++ b/drivers/dpll/dpll_netlink.c
@@ -1093,9 +1093,10 @@ int dpll_nl_pin_id_get_doit(struct sk_buff *skb, struct genl_info *info)
 		return -ENOMEM;
 	hdr = genlmsg_put_reply(msg, info, &dpll_nl_family, 0,
 				DPLL_CMD_PIN_ID_GET);
-	if (!hdr)
+	if (!hdr) {
+		nlmsg_free(msg);
 		return -EMSGSIZE;
-
+	}
 	pin = dpll_pin_find_from_nlattr(info);
 	if (!IS_ERR(pin)) {
 		ret = dpll_msg_add_pin_handle(msg, pin);
@@ -1123,8 +1124,10 @@ int dpll_nl_pin_get_doit(struct sk_buff *skb, struct genl_info *info)
 		return -ENOMEM;
 	hdr = genlmsg_put_reply(msg, info, &dpll_nl_family, 0,
 				DPLL_CMD_PIN_GET);
-	if (!hdr)
+	if (!hdr) {
+		nlmsg_free(msg);
 		return -EMSGSIZE;
+	}
 	ret = dpll_cmd_pin_get_one(msg, pin, info->extack);
 	if (ret) {
 		nlmsg_free(msg);
@@ -1256,8 +1259,10 @@ int dpll_nl_device_id_get_doit(struct sk_buff *skb, struct genl_info *info)
 		return -ENOMEM;
 	hdr = genlmsg_put_reply(msg, info, &dpll_nl_family, 0,
 				DPLL_CMD_DEVICE_ID_GET);
-	if (!hdr)
+	if (!hdr) {
+		nlmsg_free(msg);
 		return -EMSGSIZE;
+	}
 
 	dpll = dpll_device_find_from_nlattr(info);
 	if (!IS_ERR(dpll)) {
@@ -1284,8 +1289,10 @@ int dpll_nl_device_get_doit(struct sk_buff *skb, struct genl_info *info)
 		return -ENOMEM;
 	hdr = genlmsg_put_reply(msg, info, &dpll_nl_family, 0,
 				DPLL_CMD_DEVICE_GET);
-	if (!hdr)
+	if (!hdr) {
+		nlmsg_free(msg);
 		return -EMSGSIZE;
+	}
 
 	ret = dpll_device_get_one(dpll, msg, info->extack);
 	if (ret) {
-- 
2.25.1


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

* Re: [PATCH v2] dpll: Fix potential msg memleak when genlmsg_put_reply failed
  2023-11-21  1:37 ` [PATCH v2] dpll: Fix potential msg memleak when genlmsg_put_reply failed Hao Ge
@ 2023-11-21 11:20   ` Vadim Fedorenko
  2023-11-22  1:50   ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Vadim Fedorenko @ 2023-11-21 11:20 UTC (permalink / raw)
  To: Hao Ge, arkadiusz.kubalewski
  Cc: jiri, michal.michalik, davem, linux-kernel, netdev

On 21/11/2023 20:37, Hao Ge wrote:
> We should clean the skb resource if genlmsg_put_reply failed.
> 
> Fixes: 9d71b54b65b1 ("dpll: netlink: Add DPLL framework base functions")
> Signed-off-by: Hao Ge <gehao@kylinos.cn>
> ---
> v1 -> v2: change title due to add some similar fix for some similar cases
> ---
>   drivers/dpll/dpll_netlink.c | 17 ++++++++++++-----
>   1 file changed, 12 insertions(+), 5 deletions(-)

Thanks!

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>


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

* Re: [PATCH v2] dpll: Fix potential msg memleak when genlmsg_put_reply failed
  2023-11-21  1:37 ` [PATCH v2] dpll: Fix potential msg memleak when genlmsg_put_reply failed Hao Ge
  2023-11-21 11:20   ` Vadim Fedorenko
@ 2023-11-22  1:50   ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-11-22  1:50 UTC (permalink / raw)
  To: Hao Ge
  Cc: vadim.fedorenko, arkadiusz.kubalewski, jiri, michal.michalik,
	davem, linux-kernel, netdev

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 21 Nov 2023 09:37:09 +0800 you wrote:
> We should clean the skb resource if genlmsg_put_reply failed.
> 
> Fixes: 9d71b54b65b1 ("dpll: netlink: Add DPLL framework base functions")
> Signed-off-by: Hao Ge <gehao@kylinos.cn>
> ---
> v1 -> v2: change title due to add some similar fix for some similar cases
> 
> [...]

Here is the summary with links:
  - [v2] dpll: Fix potential msg memleak when genlmsg_put_reply failed
    https://git.kernel.org/netdev/net/c/b6fe6f03716d

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-11-22  1:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <0c6e0cd5-d975-41cc-824e-10b5e28251a2@linux.dev>
2023-11-21  1:37 ` [PATCH v2] dpll: Fix potential msg memleak when genlmsg_put_reply failed Hao Ge
2023-11-21 11:20   ` Vadim Fedorenko
2023-11-22  1:50   ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).