* [PATCH net v2] Check for skb_put_padto return value
@ 2017-05-07 17:15 Peter Heise
2017-05-08 19:03 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Peter Heise @ 2017-05-07 17:15 UTC (permalink / raw)
To: netdev; +Cc: mail
Return value of skb_put_padto is now checked as
reported by Dan Carpenter. skb might be freed in
case of error in skb_put_padto.
---
net/hsr/hsr_device.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
index c73160fb11e7..a1545d09a3c9 100644
--- a/net/hsr/hsr_device.c
+++ b/net/hsr/hsr_device.c
@@ -314,7 +314,8 @@ static void send_hsr_supervision_frame(struct hsr_port *master,
hsr_sp = (typeof(hsr_sp)) skb_put(skb, sizeof(struct hsr_sup_payload));
ether_addr_copy(hsr_sp->MacAddressA, master->dev->dev_addr);
- skb_put_padto(skb, ETH_ZLEN + HSR_HLEN);
+ if (skb_put_padto(skb, ETH_ZLEN + HSR_HLEN))
+ return;
hsr_forward_skb(skb, master);
return;
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net v2] Check for skb_put_padto return value
2017-05-07 17:15 [PATCH net v2] Check for skb_put_padto return value Peter Heise
@ 2017-05-08 19:03 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-05-08 19:03 UTC (permalink / raw)
To: mail; +Cc: netdev
From: Peter Heise <mail@pheise.de>
Date: Sun, 7 May 2017 17:15:26 +0000
> Return value of skb_put_padto is now checked as
> reported by Dan Carpenter. skb might be freed in
> case of error in skb_put_padto.
> ---
> net/hsr/hsr_device.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
> index c73160fb11e7..a1545d09a3c9 100644
> --- a/net/hsr/hsr_device.c
> +++ b/net/hsr/hsr_device.c
> @@ -314,7 +314,8 @@ static void send_hsr_supervision_frame(struct hsr_port *master,
> hsr_sp = (typeof(hsr_sp)) skb_put(skb, sizeof(struct hsr_sup_payload));
> ether_addr_copy(hsr_sp->MacAddressA, master->dev->dev_addr);
>
> - skb_put_padto(skb, ETH_ZLEN + HSR_HLEN);
> + if (skb_put_padto(skb, ETH_ZLEN + HSR_HLEN))
> + return;
>
> hsr_forward_skb(skb, master);
> return;
You're adding a more serious bug than the one you are fixing.
Now, if skb_put_padto() fails, we leak the SKB.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-05-08 19:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-07 17:15 [PATCH net v2] Check for skb_put_padto return value Peter Heise
2017-05-08 19:03 ` David Miller
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).