aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/nlmon.c
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-06-27 07:44:26 -0400
committerDavid S. Miller <davem@davemloft.net>2013-06-29 01:09:27 -0400
commit3b233fe0435518169af03027aedc83d42eb28ac4 (patch)
tree9306d51813bf8f2c3d83ce7cbc6b9455481d595f /drivers/net/nlmon.c
parentcf6122be45de68bc773f64e4266db76129ea556f (diff)
nlmon: fix comparison in nlmon_is_valid_mtu
This patch fixes the following warning introduced in e4fc408e0e99 ("packet: nlmon: virtual netlink monitoring device for packet sockets") reported by Dan Carpenter: warning: "drivers/net/nlmon.c:31 nlmon_is_valid_mtu() warn: always true condition '(new_mtu <= ((~0 >> 1))) => (s32min-s32max <= s32max)'" Thus, we should simply remove the test against INT_MAX. Next to that we also need to explicitly cast the sizeof() case as the comparison is type promoted to unsigned long so negative values are then valid instead of invalid. While at it, this also adds a comment about Netlink and MTUs. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/nlmon.c')
-rw-r--r--drivers/net/nlmon.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/net/nlmon.c b/drivers/net/nlmon.c
index dc364be6e61e..a0baf56f5826 100644
--- a/drivers/net/nlmon.c
+++ b/drivers/net/nlmon.c
@@ -28,7 +28,11 @@ static netdev_tx_t nlmon_xmit(struct sk_buff *skb, struct net_device *dev)
28 28
29static int nlmon_is_valid_mtu(int new_mtu) 29static int nlmon_is_valid_mtu(int new_mtu)
30{ 30{
31 return new_mtu >= sizeof(struct nlmsghdr) && new_mtu <= INT_MAX; 31 /* Note that in netlink we do not really have an upper limit. On
32 * default, we use NLMSG_GOODSIZE. Here at least we should make
33 * sure that it's at least the header size.
34 */
35 return new_mtu >= (int) sizeof(struct nlmsghdr);
32} 36}
33 37
34static int nlmon_change_mtu(struct net_device *dev, int new_mtu) 38static int nlmon_change_mtu(struct net_device *dev, int new_mtu)