2015-07-08 06:57:30

by Maninder Singh

[permalink] [raw]
Subject: [PATCH 1/1] drivers/rtc/rtc-bq32k.c: remove redundant check

removing below static analysis error:-
(error) Possible null pointer dereference: client

if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
^^^^^^^
Error comes beacause client is dereferenced before NULL check.
So probabily NULL this check is not required.

Signed-off-by: Maninder Singh <[email protected]>
---
drivers/rtc/rtc-bq32k.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c
index 92679df..409de9f 100644
--- a/drivers/rtc/rtc-bq32k.c
+++ b/drivers/rtc/rtc-bq32k.c
@@ -212,7 +212,7 @@ static int bq32k_probe(struct i2c_client *client,
if (error)
return error;

- if (client && client->dev.of_node)
+ if (client->dev.of_node)
trickle_charger_of_init(dev, client->dev.of_node);

rtc = devm_rtc_device_register(&client->dev, bq32k_driver.driver.name,
--
1.7.9.5


2015-07-14 22:41:41

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH 1/1] drivers/rtc/rtc-bq32k.c: remove redundant check

Hi,

On 08/07/2015 at 12:26:47 +0530, Maninder Singh wrote :
> removing below static analysis error:-

What tool did you use?

> (error) Possible null pointer dereference: client
>
> if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
> ^^^^^^^
> Error comes beacause client is dereferenced before NULL check.
> So probabily NULL this check is not required.
>
> Signed-off-by: Maninder Singh <[email protected]>
> ---
> drivers/rtc/rtc-bq32k.c | 2 +-
Applied, to rtc-next.

--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com