mfd: add null check before pointer dereference
Subsystems (2)
PATCH 1/1 mfd: add null check before pointer dereference
Add NULL check before dereferencing pointer of_id in order to avoid a potential NULL pointer dereference.
Addresses-Coverity-ID: 1408829
--- drivers/mfd/wm831x-i2c.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mfd/wm831x-i2c.c +4 -0
@@ -37,6 +37,10 @@ static int wm831x_i2c_probe(struct i2c_client *i2c,if (i2c->dev.of_node) { of_id =of_match_device (wm831x_of_match, &i2c->dev); +if (!of_id) { +dev_err (&i2c->dev,"Failed to find matching id\n" ); +return -EINVAL ; + } type = (enum wm831x_parent )of_id->data; }else { type = (enum wm831x_parent )id->driver_data;
Signature · 1 line
2.5.0
Quoted 7 lines · Gustavo A. R. Silva
Add NULL check before dereferencing pointer
of_idin order to avoid a potential NULL pointer dereference.Addresses-Coverity-ID: 1408829
Cc Charles Keepax <[email protected]>Signed-off-by Gustavo A. R. Silva <[email protected]>---
Thanks,
Charles
PATCH v2 1/1 mfd: wm831x: add null check before pointer dereference
In reply to Gustavo A. R. SilvaAdd NULL check before dereferencing pointer of_id in order to avoid a potential NULL pointer dereference.
Addresses-Coverity-ID: 1408829
---
Changes in v2:
Update error log and return value.
drivers/mfd/wm831x-i2c.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mfd/wm831x-i2c.c +4 -0
@@ -37,6 +37,10 @@ static int wm831x_i2c_probe(struct i2c_client *i2c,if (i2c->dev.of_node) { of_id =of_match_device (wm831x_of_match, &i2c->dev); +if (!of_id) { +dev_err (&i2c->dev,"Failed to match device\n" ); +return -ENODEV ; + } type = (enum wm831x_parent )of_id->data; }else { type = (enum wm831x_parent )id->driver_data;
Signature · 1 line
2.5.0
Lee Jones
AppliedRe: [PATCH v2] mfd: wm831x: add null check before pointer dereference
Quoted 7 lines · Gustavo A. R. Silva
Add NULL check before dereferencing pointer
of_idin order to avoid a potential NULL pointer dereference.Addresses-Coverity-ID: 1408829
Cc Lee Jones <[email protected]>Cc Charles Keepax <[email protected]>Signed-off-by Gustavo A. R. Silva <[email protected]>
Quoted 6 lines
---
Changes in v2:
Update error log and return value.drivers/mfd/wm831x-i2c.c | 4 ++++ 1 file changed, 4 insertions(+)
Applied, thanks.
Quoted 15 lines
drivers/mfd/wm831x-i2c.c +4
-0@@ -37,6 +37,10 @@ static int wm831x_i2c_probe(struct i2c_client *i2c,if (i2c->dev.of_node) { of_id =of_match_device (wm831x_of_match, &i2c->dev); +if (!of_id) { +dev_err (&i2c->dev,"Failed to match device\n" ); +return -ENODEV ; + } type = (enum wm831x_parent )of_id->data; }else { type = (enum wm831x_parent )id->driver_data;
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog