All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] devlink: fix potential memort leak
@ 2017-06-04 12:49 Haishuang Yan
  2017-06-04 13:07 ` Arkadi Sharshevsky
  0 siblings, 1 reply; 2+ messages in thread
From: Haishuang Yan @ 2017-06-04 12:49 UTC (permalink / raw)
  To: David S. Miller, Arkadi Sharshevsky, Jiri Pirko
  Cc: netdev, linux-kernel, Haishuang Yan

We must free allocated skb when genlmsg_put() return fails.

Fixes: 1555d204e743 ("devlink: Support for pipeline debug (dpipe)")
Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
 net/core/devlink.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index b0b87a2..70b69c6 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -1680,8 +1680,10 @@ static int devlink_dpipe_tables_fill(struct genl_info *info,
 
 	hdr = genlmsg_put(skb, info->snd_portid, info->snd_seq,
 			  &devlink_nl_family, NLM_F_MULTI, cmd);
-	if (!hdr)
+	if (!hdr) {
+		nlmsg_free(skb);
 		return -EMSGSIZE;
+	}
 
 	if (devlink_nl_put_handle(skb, devlink))
 		goto nla_put_failure;
-- 
1.8.3.1

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

* Re: [PATCH] devlink: fix potential memort leak
  2017-06-04 12:49 [PATCH] devlink: fix potential memort leak Haishuang Yan
@ 2017-06-04 13:07 ` Arkadi Sharshevsky
  0 siblings, 0 replies; 2+ messages in thread
From: Arkadi Sharshevsky @ 2017-06-04 13:07 UTC (permalink / raw)
  To: Haishuang Yan, David S. Miller, Jiri Pirko; +Cc: netdev, linux-kernel



On 06/04/2017 03:49 PM, Haishuang Yan wrote:
> We must free allocated skb when genlmsg_put() return fails.
> 
> Fixes: 1555d204e743 ("devlink: Support for pipeline debug (dpipe)")
> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
> ---
>  net/core/devlink.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/net/core/devlink.c b/net/core/devlink.c
> index b0b87a2..70b69c6 100644
> --- a/net/core/devlink.c
> +++ b/net/core/devlink.c
> @@ -1680,8 +1680,10 @@ static int devlink_dpipe_tables_fill(struct genl_info *info,
>  
>  	hdr = genlmsg_put(skb, info->snd_portid, info->snd_seq,
>  			  &devlink_nl_family, NLM_F_MULTI, cmd);
> -	if (!hdr)
> +	if (!hdr) {
> +		nlmsg_free(skb);
>  		return -EMSGSIZE;
> +	}
>  
>  	if (devlink_nl_put_handle(skb, devlink))
>  		goto nla_put_failure;
> 

Thanks! I think it a bit better to set the err and goto
down the error path below (only nlmsg_free()). Headrs_fill()
also suffers from this problem.

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

end of thread, other threads:[~2017-06-04 13:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-04 12:49 [PATCH] devlink: fix potential memort leak Haishuang Yan
2017-06-04 13:07 ` Arkadi Sharshevsky

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.