Re: [PATCH v2] hdlcdrv: fix divide error bug if bitrate is 0
From: David Miller <davem@davemloft.net>
Date: 2017-05-19 21:41:17
Also in:
linux-hams
From: David Miller <davem@davemloft.net>
Date: 2017-05-19 21:41:17
Also in:
linux-hams
From: Firo Yang <redacted> Date: Fri, 19 May 2017 21:21:46 +0800
@@ -576,6 +576,10 @@ static int hdlcdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) case HDLCDRVCTL_CALIBRATE: if(!capable(CAP_SYS_RAWIO)) return -EPERM; + if (!netif_running(dev)) + return -ENODEV; + if (!(s->par.bitrate > 0)) + return -EINVAL;
This test is so un-canonical and convoluted. Please use something more straightforward. I really think Alan Cox's patch handled this more cleanly. Make the test something like "if (x <= 0) return -EINVAL;". I also am not convinced about the netif_running() test and at best it is a separate change from this divide by zero bug fix so belongs in a separate patch. Thank you.