From: Paul Menzel <pmenzel+linux-hwmon@molgen.mpg.de>
To: Guenter Roeck <linux@roeck-us.net>, Jean Delvare <jdelvare@suse.com>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: nct6775: UBSAN: shift exponent 32 is too large for 32-bit type 'long unsigned int'
Date: Tue, 12 Jun 2018 23:50:45 +0200 [thread overview]
Message-ID: <d02001e2-fa4c-6a2e-cc50-a8d9a8146d57@molgen.mpg.de> (raw)
Dear Guenther, dear Jean,
Building Linux with the undefined behavior sanitizer (UBSAN), loading
the module *nct6775* on the ASRock E350M1 shows the error below.
```
[ 28.322775] UBSAN: Undefined behaviour in drivers/hwmon/nct6775.c:4179:27
[ 28.322833] shift exponent 32 is too large for 32-bit type 'long
unsigned int'
```
I believe this was introduced by commit cc66b3038254 (hwmon: (nct6775)
Rework temperature source and label handling), but the same issue was
already present before.
```
- for (i = 0; i < data->temp_label_num - 1; i++) {
+ for (i = 0; i < 32; i++) {
+ if (!(data->temp_mask & BIT(i + 1)))
+ continue;
```
`include/linux/bitops.h` has the macros below.
```
#define BIT(nr) (1UL << (nr))
#define BIT_ULL(nr) (1ULL << (nr))
```
Maybe `BIT_ULL` should be used, but I do not know, if that’d would work
with `data->temp_mask`, which has type `u32`.
Kind regards,
Paul
next reply other threads:[~2018-06-12 21:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-12 21:50 Paul Menzel [this message]
2018-06-12 22:12 ` nct6775: UBSAN: shift exponent 32 is too large for 32-bit type 'long unsigned int' Guenter Roeck
2018-06-13 6:57 ` Paul Menzel
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=d02001e2-fa4c-6a2e-cc50-a8d9a8146d57@molgen.mpg.de \
--to=pmenzel+linux-hwmon@molgen.mpg.de \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/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).