drivers/i2c/generic: Ensure config is not NULL before accessing it
This change checks to ensure that config is not NULL before it is accessed for the first time. Reported by: Coverity CID #1393312 Change-Id: Ic248c79783da9c2bfdf3b7f737e5963feff7558c Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://review.coreboot.org/27009 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Naresh Solanki <naresh.solanki@intel.com>
This commit is contained in:
parent
e9147bdf11
commit
24681f188a
|
@ -202,6 +202,9 @@ static void i2c_generic_enable(struct device *dev)
|
||||||
{
|
{
|
||||||
struct drivers_i2c_generic_config *config = dev->chip_info;
|
struct drivers_i2c_generic_config *config = dev->chip_info;
|
||||||
|
|
||||||
|
if (!config)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Check if device is present by reading GPIO */
|
/* Check if device is present by reading GPIO */
|
||||||
if (config->device_present_gpio) {
|
if (config->device_present_gpio) {
|
||||||
int present = gpio_get(config->device_present_gpio);
|
int present = gpio_get(config->device_present_gpio);
|
||||||
|
@ -219,9 +222,8 @@ static void i2c_generic_enable(struct device *dev)
|
||||||
dev->ops = &i2c_generic_ops;
|
dev->ops = &i2c_generic_ops;
|
||||||
|
|
||||||
/* Name the device as per description provided in devicetree */
|
/* Name the device as per description provided in devicetree */
|
||||||
if (config && config->desc) {
|
if (config->desc)
|
||||||
dev->name = config->desc;
|
dev->name = config->desc;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct chip_operations drivers_i2c_generic_ops = {
|
struct chip_operations drivers_i2c_generic_ops = {
|
||||||
|
|
Loading…
Reference in New Issue