All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Colin King <colin.king@canonical.com>
Cc: Ian Abbott <abbotti@mev.co.uk>,
	H Hartley Sweeten <hsweeten@visionengravers.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: comedi: dt2811: fix integer overflow in multiply
Date: Mon, 04 Feb 2019 07:48:20 +0000	[thread overview]
Message-ID: <20190204074820.GC2581@kadam> (raw)
In-Reply-To: <20190203112904.GA2563@kadam>

On Sun, Feb 03, 2019 at 02:29:04PM +0300, Dan Carpenter wrote:
> > diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c
> > index 05207a519755..820e75f850ff 100644
> > --- a/drivers/staging/comedi/drivers/dt2811.c
> > +++ b/drivers/staging/comedi/drivers/dt2811.c
> > @@ -323,7 +323,8 @@ static unsigned int dt2811_ns_to_timer(unsigned int *nanosec,
> >  		for (_mult = 0; _mult <= 7; _mult++) {
> >  			unsigned int div = dt2811_clk_dividers[_div];
> >  			unsigned int mult = dt2811_clk_multipliers[_mult];
> > -			unsigned long long divider = div * mult;
> > +			unsigned long long divider > > +				(unsigned long long)div * mult;
> 
> The max "div" can be is 12.  The max "mult" can be is 10,000,000.  So
> this is a false positive because there is no overflow.  The code is not
> complicated.  Unfortunately, Smatch has the exact same problem...

Smatch actually parses this correctly, but I had a power failure over
the weekend that messed up my results.

regards,
dan carpenter

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Colin King <colin.king@canonical.com>
Cc: Ian Abbott <abbotti@mev.co.uk>,
	H Hartley Sweeten <hsweeten@visionengravers.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: comedi: dt2811: fix integer overflow in multiply
Date: Mon, 4 Feb 2019 10:48:20 +0300	[thread overview]
Message-ID: <20190204074820.GC2581@kadam> (raw)
In-Reply-To: <20190203112904.GA2563@kadam>

On Sun, Feb 03, 2019 at 02:29:04PM +0300, Dan Carpenter wrote:
> > diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c
> > index 05207a519755..820e75f850ff 100644
> > --- a/drivers/staging/comedi/drivers/dt2811.c
> > +++ b/drivers/staging/comedi/drivers/dt2811.c
> > @@ -323,7 +323,8 @@ static unsigned int dt2811_ns_to_timer(unsigned int *nanosec,
> >  		for (_mult = 0; _mult <= 7; _mult++) {
> >  			unsigned int div = dt2811_clk_dividers[_div];
> >  			unsigned int mult = dt2811_clk_multipliers[_mult];
> > -			unsigned long long divider = div * mult;
> > +			unsigned long long divider =
> > +				(unsigned long long)div * mult;
> 
> The max "div" can be is 12.  The max "mult" can be is 10,000,000.  So
> this is a false positive because there is no overflow.  The code is not
> complicated.  Unfortunately, Smatch has the exact same problem...

Smatch actually parses this correctly, but I had a power failure over
the weekend that messed up my results.

regards,
dan carpenter


  reply	other threads:[~2019-02-04  7:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-02 21:59 [PATCH] staging: comedi: dt2811: fix integer overflow in multiply Colin King
2019-02-02 21:59 ` Colin King
2019-02-03 11:29 ` Dan Carpenter
2019-02-03 11:29   ` Dan Carpenter
2019-02-04  7:48   ` Dan Carpenter [this message]
2019-02-04  7:48     ` Dan Carpenter

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=20190204074820.GC2581@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=abbotti@mev.co.uk \
    --cc=colin.king@canonical.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hsweeten@visionengravers.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.