diff options
author | Martin Roth <gaumless@gmail.com> | 2023-10-23 17:47:03 -0600 |
---|---|---|
committer | Felix Singer <service+coreboot-gerrit@felixsinger.de> | 2023-12-20 17:01:49 +0000 |
commit | fab89b34e70dd52450db86dc115317fcb1d42ebe (patch) | |
tree | f8a4a9623492e5d901589fe84bdc2bf397c2448f | |
parent | 9bcbdbf9e48f3977cf5d48732527bbf02fea02de (diff) |
device/i2c_bus.c: Check pointer for NULL before using it
Found-by: Coverity Scan #1489753
Signed-off-by: Martin Roth <gaumless@gmail.com>
Change-Id: I4f3794cf17875cdb35010c79a6537a4c13a18224
Reviewed-on: https://review.coreboot.org/c/coreboot/+/78615
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de>
-rw-r--r-- | src/device/i2c_bus.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/device/i2c_bus.c b/src/device/i2c_bus.c index 361bb67df8..1d4aa2d2b3 100644 --- a/src/device/i2c_bus.c +++ b/src/device/i2c_bus.c @@ -11,6 +11,8 @@ bool i2c_dev_detect(struct device *dev, unsigned int addr) { struct i2c_msg seg = { .flags = 0, .slave = addr, .buf = NULL, .len = 0 }; + if (!dev) + return false; return dev->ops->ops_i2c_bus->transfer(dev, &seg, 1) == 0; } |