Skip to contentSkip to conversation

Coverity: bcm54140_hwmon_read_in(): Control flow issues

DISCUSSION coverity-bot 1 participant 1 message Apr 23, 2020 Linux-next tree

lore
Share & tools
lore
#0 lore raw

Hello!

This is an experimental semi-automated report about issues detected by Coverity from a scan of next-20200423 as part of the linux-next scan project:
https://scan.coverity.com/projects/linux-next-weekly-scan

You're getting this email because you were associated with the identified lines of code (noted below) that were touched by commits:

Mon Apr 20 20:21:13 2020 +0200

    4406d36dfdf1 ("net: phy: bcm54140: add hwmon support")

Coverity reported the following:

*** CID 1492709: Control flow issues (NO_EFFECT) /drivers/net/phy/bcm54140.c: 247 in bcm54140_hwmon_read_in()

241     		return bcm54140_hwmon_read_alarm(dev, bit, val);
242     	default:
243     		return -EOPNOTSUPP;
244     	}
245
246     	tmp = bcm_phy_read_rdb(phydev, reg);
vvv     CID 1492709:  Control flow issues  (NO_EFFECT)
vvv     This less-than-zero comparison of an unsigned value is never true. "tmp < 0".
247     	if (tmp < 0)
248     		return tmp;

249
250 tmp &= BCM54140_HWMON_IN_MASK(channel);
251 *val = BCM54140_HWMON_TO_IN(channel, tmp);
252

If this is a false positive, please let us know so we can mark it as such, or teach the Coverity rules to be smarter. If not, please make sure fixes get into linux-next. :) For patches fixing this, please include these lines (but double-check the "Fixes" first):

Human edit:
This is present on line 214 as well. (bcm_phy_read_rdb() returns int, but tmp is u16.)

Addresses-Coverity-ID: 1492709 ("Control flow issues")

Fixes 4406d36dfdf1 ("net: phy: bcm54140: add hwmon support")

Thanks for your attention!

Signature · 1 line
Coverity-bot