[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170517123549.22659-1-firogm@gmail.com>
Date: Wed, 17 May 2017 20:35:49 +0800
From: Firo Yang <firogm@...il.com>
To: t.sailer@...mni.ethz.ch
Cc: davem@...emloft.net, gregkh@...uxfoundation.org,
linux-hams@...r.kernel.org, netdev@...r.kernel.org,
dvyukov@...gle.com, syzkaller@...glegroups.com,
Firo Yang <firogm@...il.com>
Subject: [PATCH] hdlcdrv: fix divide error bug if bitrate is 0
The divisor s->par.bitrate will always be 0 until initialized by
ndo_open() and hdlcdrv_open().
In order to fix this divide zero error, check whether the netdevice
was opened by ndo_open() before performing divide.
Reported-by: Dmitry Vyukov <dvyukov@...gle.com>
Signed-off-by: Firo Yang <firogm@...il.com>
---
drivers/net/hamradio/hdlcdrv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index 8c3633c..3c783fd 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -574,7 +574,7 @@ static int hdlcdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
break;
case HDLCDRVCTL_CALIBRATE:
- if(!capable(CAP_SYS_RAWIO))
+ if (!capable(CAP_SYS_RAWIO) || !netif_running(dev))
return -EPERM;
if (bi.data.calibrate > INT_MAX / s->par.bitrate)
return -EINVAL;
--
2.9.4
Powered by blists - more mailing lists