* [PATCH 2/18] gdm72xx: Move away from NLMSG_PUT().
@ 2012-06-27 5:02 David Miller
2012-06-27 11:07 ` Javier Martinez Canillas
0 siblings, 1 reply; 2+ messages in thread
From: David Miller @ 2012-06-27 5:02 UTC (permalink / raw)
To: netdev
And use nlmsg_data() while we're here too.
Signed-off-by: David S. Miller <davem@davemloft.net>
---
drivers/staging/gdm72xx/netlink_k.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/gdm72xx/netlink_k.c b/drivers/staging/gdm72xx/netlink_k.c
index 292af0f..d0cb48a 100644
--- a/drivers/staging/gdm72xx/netlink_k.c
+++ b/drivers/staging/gdm72xx/netlink_k.c
@@ -127,8 +127,12 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len)
}
seq++;
- nlh = NLMSG_PUT(skb, 0, seq, type, len);
- memcpy(NLMSG_DATA(nlh), msg, len);
+ nlh = nlmsg_put(skb, 0, seq, type, len, 0);
+ if (!nlh) {
+ kfree_skb(skb);
+ return -EMSGSIZE;
+ }
+ memcpy(nlmsg_data(nlh), msg, len);
NETLINK_CB(skb).pid = 0;
NETLINK_CB(skb).dst_group = 0;
@@ -144,7 +148,5 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len)
}
ret = 0;
}
-
-nlmsg_failure:
return ret;
}
--
1.7.10.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/18] gdm72xx: Move away from NLMSG_PUT().
2012-06-27 5:02 [PATCH 2/18] gdm72xx: Move away from NLMSG_PUT() David Miller
@ 2012-06-27 11:07 ` Javier Martinez Canillas
0 siblings, 0 replies; 2+ messages in thread
From: Javier Martinez Canillas @ 2012-06-27 11:07 UTC (permalink / raw)
To: David Miller; +Cc: netdev
On Wed, Jun 27, 2012 at 7:02 AM, David Miller <davem@davemloft.net> wrote:
>
> And use nlmsg_data() while we're here too.
>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> ---
> drivers/staging/gdm72xx/netlink_k.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/gdm72xx/netlink_k.c b/drivers/staging/gdm72xx/netlink_k.c
> index 292af0f..d0cb48a 100644
> --- a/drivers/staging/gdm72xx/netlink_k.c
> +++ b/drivers/staging/gdm72xx/netlink_k.c
> @@ -127,8 +127,12 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len)
> }
>
> seq++;
> - nlh = NLMSG_PUT(skb, 0, seq, type, len);
> - memcpy(NLMSG_DATA(nlh), msg, len);
> + nlh = nlmsg_put(skb, 0, seq, type, len, 0);
> + if (!nlh) {
> + kfree_skb(skb);
> + return -EMSGSIZE;
> + }
> + memcpy(nlmsg_data(nlh), msg, len);
>
> NETLINK_CB(skb).pid = 0;
> NETLINK_CB(skb).dst_group = 0;
> @@ -144,7 +148,5 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len)
> }
> ret = 0;
> }
> -
> -nlmsg_failure:
> return ret;
> }
> --
> 1.7.10.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi David,
This also solves an skb memory leak since the sk_buff was allocated
before the NLMSG_PUT() macro and not freed after jumping to the
nlmsg_failure label. I posted a similar patch before:
http://www.spinics.net/lists/linux-driver-devel/msg25756.html
and is already on linux-next with commitid:
2da049bd5f9b0dbd688519fdb6688a4895fe8395 staging: gdm72xx: fix an skb
memory leak
Best regards,
Javier
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-06-27 11:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-27 5:02 [PATCH 2/18] gdm72xx: Move away from NLMSG_PUT() David Miller
2012-06-27 11:07 ` Javier Martinez Canillas
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).