Skip to content

Commit 10cae1c

Browse files
ralfbaechledavem330
authored andcommitted
NET: NETROM: Cleanup argument SIOCADDRT ioctl argument checking.
nr_route.ndigis is unsigned int so the nr_route.ndigis < 0 expression is never true and can be dropped. Doing the nr_ax25_dev_get call later allows the nr_route.ndigis test to bail out without having to dev_put. Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Cc: Thomas Osterried <thomas@osterried.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ac1a1de commit 10cae1c

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎net/netrom/nr_route.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -670,12 +670,10 @@ int nr_rt_ioctl(unsigned int cmd, void __user *arg)
670670
case SIOCADDRT:
671671
if (copy_from_user(&nr_route, arg, sizeof(struct nr_route_struct)))
672672
return -EFAULT;
673-
if ((dev = nr_ax25_dev_get(nr_route.device)) == NULL)
673+
if (nr_route.ndigis > AX25_MAX_DIGIS)
674674
return -EINVAL;
675-
if (nr_route.ndigis < 0 || nr_route.ndigis > AX25_MAX_DIGIS) {
676-
dev_put(dev);
675+
if ((dev = nr_ax25_dev_get(nr_route.device)) == NULL)
677676
return -EINVAL;
678-
}
679677
switch (nr_route.type) {
680678
case NETROM_NODE:
681679
if (strnlen(nr_route.mnemonic, 7) == 7) {

0 commit comments

Comments
 (0)