netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: firogm@gmail.com
Cc: t.sailer@alumni.ethz.ch, wharms@bfs.de, andreyknvl@google.com,
	linux-hams@vger.kernel.org, gregkh@linuxfoundation.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH v2] hdlcdrv: fix divide error bug if bitrate is 0
Date: Fri, 19 May 2017 17:41:17 -0400 (EDT)	[thread overview]
Message-ID: <20170519.174117.491042433043886205.davem@davemloft.net> (raw)
In-Reply-To: <20170519132146.744-1-firogm@gmail.com>

From: Firo Yang <firogm@gmail.com>
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.

  reply	other threads:[~2017-05-19 21:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-16 15:05 drivers/net/hamradio: divide error in hdlcdrv_ioctl Andrey Konovalov
2017-05-16 15:05 ` Andrey Konovalov
2017-05-17 20:07 ` Alan Cox
2017-05-19  0:29   ` Andrey Konovalov
2017-05-19 13:21 ` [PATCH v2] hdlcdrv: fix divide error bug if bitrate is 0 Firo Yang
2017-05-19 21:41   ` David Miller [this message]
2017-05-26 14:37 ` [PATCH v3] hdlcdrv: Fix divide by zero in hdlcdrv_ioctl Firo Yang
2017-05-27 22:45   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170519.174117.491042433043886205.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=andreyknvl@google.com \
    --cc=firogm@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-hams@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=t.sailer@alumni.ethz.ch \
    --cc=wharms@bfs.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).