ASoC: max98373: check for device node before parsing
Below Oops is caused in a system which uses ACPI instead of device node: of_get_named_gpiod_flags: can't parse 'maxim,reset-gpio' property of node '(null)[0]' BUG: kernel NULL pointer dereference, address: 0000000000000010 This patch avoids NULL pointer deferencing by adding a check before parsing and initializes to make reset-gpio pin as invalid. Signed-off-by: Sathyanarayana Nujella <sathyanarayana.nujella@intel.com> Signed-off-by: Jairaj Arava <jairaj.arava@intel.com> Link: https://lore.kernel.org/r/1569702150-11976-1-git-send-email-sathyanarayana.nujella@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
752c938a5c
commit
4bb41984bf
|
@ -901,7 +901,7 @@ static void max98373_slot_config(struct i2c_client *i2c,
|
|||
max98373->i_slot = value & 0xF;
|
||||
else
|
||||
max98373->i_slot = 1;
|
||||
|
||||
if (dev->of_node) {
|
||||
max98373->reset_gpio = of_get_named_gpio(dev->of_node,
|
||||
"maxim,reset-gpio", 0);
|
||||
if (!gpio_is_valid(max98373->reset_gpio)) {
|
||||
|
@ -912,6 +912,10 @@ static void max98373_slot_config(struct i2c_client *i2c,
|
|||
dev_dbg(dev, "maxim,reset-gpio=%d",
|
||||
max98373->reset_gpio);
|
||||
}
|
||||
} else {
|
||||
/* this makes reset_gpio as invalid */
|
||||
max98373->reset_gpio = -1;
|
||||
}
|
||||
|
||||
if (!device_property_read_u32(dev, "maxim,spkfb-slot-no", &value))
|
||||
max98373->spkfb_slot = value & 0xF;
|
||||
|
|
Loading…
Reference in New Issue