From fab89b34e70dd52450db86dc115317fcb1d42ebe Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Mon, 23 Oct 2023 17:47:03 -0600 Subject: device/i2c_bus.c: Check pointer for NULL before using it Found-by: Coverity Scan #1489753 Signed-off-by: Martin Roth Change-Id: I4f3794cf17875cdb35010c79a6537a4c13a18224 Reviewed-on: https://review.coreboot.org/c/coreboot/+/78615 Tested-by: build bot (Jenkins) Reviewed-by: Matt DeVillier Reviewed-by: Felix Singer --- src/device/i2c_bus.c | 2 ++ 1 file changed, 2 insertions(+) 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; } -- cgit v1.2.3