Skip to content

Commit

Permalink
net: core: drop pointless check in __dev_alloc_name
Browse files Browse the repository at this point in the history
The only caller passes a stack buffer as buf, so it won't equal the
passed-in name. Moreover, we're already using buf as a scratch buffer
inside the if (p) {} block, so if buf and name were the same, that
snprintf() call would be overwriting its own format string.

Signed-off-by: Rasmus Villemoes <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Villemoes authored and davem330 committed Nov 14, 2017
1 parent c46d764 commit 6224abd
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1095,8 +1095,7 @@ static int __dev_alloc_name(struct net *net, const char *name, char *buf)
free_page((unsigned long) inuse);
}

if (buf != name)
snprintf(buf, IFNAMSIZ, name, i);
snprintf(buf, IFNAMSIZ, name, i);
if (!__dev_get_by_name(net, buf))
return i;

Expand Down

0 comments on commit 6224abd

Please sign in to comment.