[coreboot-gerrit] Change in coreboot[master]: soc/intel/{common, apollolake}: fix coverity issues
Rizwan Qureshi (Code Review)
gerrit at coreboot.org
Wed Oct 4 15:35:03 CEST 2017
Rizwan Qureshi has uploaded this change for review. ( https://review.coreboot.org/21875
Change subject: soc/intel/{common,apollolake}: fix coverity issues
......................................................................
soc/intel/{common,apollolake}: fix coverity issues
fix issues reported by coverity scan in the below files
src/soc/intel/common/block/i2c
1375440: Improper use of negative value
1375441: Improper use of negative value
1375444: Improper use of negative value
src/soc/intel/apollolake/i2c.c
1375442: Unsigned compared against 0
Change-Id: Ic65400c934631e3dcd3aa664c24cb451616e7f4d
Signed-off-by: Rizwan Qureshi <rizwan.qureshi at intel.com>
---
M src/soc/intel/apollolake/i2c.c
M src/soc/intel/common/block/i2c/i2c.c
2 files changed, 8 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/75/21875/1
diff --git a/src/soc/intel/apollolake/i2c.c b/src/soc/intel/apollolake/i2c.c
index 2b6cbf9..4ae500e 100644
--- a/src/soc/intel/apollolake/i2c.c
+++ b/src/soc/intel/apollolake/i2c.c
@@ -44,7 +44,7 @@
/* Convert I2C bus number to PCI device and function */
int i2c_soc_bus_to_devfn(unsigned int bus)
{
- if (bus >= 0 && bus <= 3)
+ if (bus <= 3)
return PCI_DEVFN(PCH_DEV_SLOT_SIO1, bus);
else if (bus >= 4 && bus <= 7)
return PCI_DEVFN(PCH_DEV_SLOT_SIO2, (bus - 4));
diff --git a/src/soc/intel/common/block/i2c/i2c.c b/src/soc/intel/common/block/i2c/i2c.c
index 625bb99..c6f3be2 100644
--- a/src/soc/intel/common/block/i2c/i2c.c
+++ b/src/soc/intel/common/block/i2c/i2c.c
@@ -96,9 +96,12 @@
const struct lpss_i2c_bus_config *config;
int bus = lpss_i2c_dev_to_bus(dev);
+ if (bus < 0)
+ return;
+
config = i2c_get_soc_cfg(bus, dev);
- if (!config || bus < 0)
+ if (!config)
return;
lpss_i2c_init(bus, config);
@@ -126,6 +129,9 @@
bus = lpss_i2c_dev_to_bus(dev);
+ if (bus < 0)
+ return;
+
bcfg = i2c_get_soc_cfg(bus, dev);
if (!bcfg)
--
To view, visit https://review.coreboot.org/21875
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic65400c934631e3dcd3aa664c24cb451616e7f4d
Gerrit-Change-Number: 21875
Gerrit-PatchSet: 1
Gerrit-Owner: Rizwan Qureshi <rizwan.qureshi at intel.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20171004/896b0877/attachment.html>
More information about the coreboot-gerrit
mailing list