Skip to contentSkip to conversation

net: ndisc.c: reduce size of __ndisc_fill_addr_option()

PATCH Alexey Dobriyan 3 participants 3 messages May 27, 2017 – May 30, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

net/ipv6/ndisc.c void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data, · line 151

Quoted 9 lines
net/ipv6/ndisc.c +2 -2
@@ -148,17 +148,18 @@ void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data,
 
 	space -= data_len;
-	if (space > 0)
-		memset(opt, 0, space);
+
+	memset(opt, 0, space);

This can't be right.

And what size are you reducing?

maintainer
#1 lore raw

From: Alexey Dobriyan <[email protected]>
Date: Sat, 27 May 2017 18:15:14 +0300

Quoted 12 lines

net/ipv6/ndisc.c void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data, · line 151

Quoted 9 lines
net/ipv6/ndisc.c +2 -2
@@ -148,17 +148,18 @@ void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data,
 
 	space -= data_len;
-	if (space > 0)
-		memset(opt, 0, space);
+
+	memset(opt, 0, space);

This can't be right.

Quoted 1 line

And what size are you reducing?

It is right, space equals the same thing it would have equaled before his changes, and a memset() of zero length will do the right thing.

Finally, if space can be negative here, we have real problems.

#2 lore raw
Quoted 15 lines · David Miller

From: Alexey Dobriyan <[email protected]>
Date: Sat, 27 May 2017 18:15:14 +0300

Quoted 12 lines

net/ipv6/ndisc.c void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data, · line 151

Quoted 9 lines
net/ipv6/ndisc.c +2 -2
@@ -148,17 +148,18 @@ void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data,
 
       space -= data_len;
-    if (space > 0)
-            memset(opt, 0, space);
+
+    memset(opt, 0, space);

This can't be right.

Quoted 7 lines
Quoted 1 line

And what size are you reducing?

It is right, space equals the same thing it would have equaled before his changes, and a memset() of zero length will do the right thing.

Finally, if space can be negative here, we have real problems.

__ndisc_fill_addr_option is exported so yeah.