From: Peter Rosin <peda@lysator.liu.se>
To: Antti Palosaari <crope@iki.fi>
Cc: linux-media@vger.kernel.org,
Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
linux-kernel@vger.kernel.org
Subject: m88ds3103: Undefined division
Date: Fri, 19 Feb 2016 11:10:28 +0100 [thread overview]
Message-ID: <56C6EA14.7080405@lysator.liu.se> (raw)
Hi!
I'm looking at this code in drivers/media/dvb-frontends/m88ds3103.c in
the m88ds3103_set_frontend() function, line 600 (give or take):
s32tmp = 0x10000 * (tuner_frequency - c->frequency);
s32tmp = DIV_ROUND_CLOSEST(s32tmp, priv->mclk_khz);
if (s32tmp < 0)
s32tmp += 0x10000;
There is code that tries to handle negative s32tmp, so I assume that
negative s32tmp is a possibility. Further, priv->mclk_khz is an unsigned
type as far as I can tell. But then we have this comment for the
DIV_ROUND_CLOSEST macro:
/*
* Divide positive or negative dividend by positive divisor and round
* to closest integer. Result is undefined for negative divisors and
* for negative dividends if the divisor variable type is unsigned.
*/
#define DIV_ROUND_CLOSEST(x, divisor)( \
I don't know how bad this is, and what the consequences of garbage are,
but from here it looks like a problem waiting to happen...
Cheers,
Peter
next reply other threads:[~2016-02-19 10:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-19 10:10 Peter Rosin [this message]
2016-02-19 10:46 ` Antti Palosaari
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=56C6EA14.7080405@lysator.liu.se \
--to=peda@lysator.liu.se \
--cc=crope@iki.fi \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@osg.samsung.com \
/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
all inboxes | Powered by JetHome®