Skip to contentSkip to conversation

w1: Fix w1_bq27000

DISCUSSION Dan Carpenter 2 participants 2 messages Feb 18, 2012 – Feb 19, 2012

lore
Share & tools
lore
#0 lore raw

Hello NeilBrown,

This is a semi-automatic email about new static checker warnings.

The patch 9f3519d2ed26: "w1: Fix w1_bq27000" from Feb 15, 2012, leads to the following Smatch complaint:

drivers/w1/slaves/w1_bq27000.c:48 w1_bq27000_read()
warn: variable dereferenced before check 'dev' (see line 46)

drivers/w1/slaves/w1_bq27000.c

    45		u8 val;
    46		struct w1_slave *sl = container_of(dev->parent, struct w1_slave, dev);
                                                   ^^^^^^^^^^^

New dereference.

    47	
    48		if (!dev)
                     ^^^

Old check.

    49			return 0;
    50	

regards,
dan carpenter

#1 lore raw
Quoted 19 lines · On Sat, 18 Feb 2012 23:51:25 +0300 Dan Carpenter <[email protected]>…

Hello NeilBrown,

This is a semi-automatic email about new static checker warnings.

The patch 9f3519d2ed26: "w1: Fix w1_bq27000" from Feb 15, 2012, leads to the following Smatch complaint:

drivers/w1/slaves/w1_bq27000.c:48 w1_bq27000_read()
warn: variable dereferenced before check 'dev' (see line 46)

drivers/w1/slaves/w1_bq27000.c

    45		u8 val;
    46		struct w1_slave *sl = container_of(dev->parent, struct w1_slave, dev);
                                                   ^^^^^^^^^^^

New dereference.

    47	
    48		if (!dev)
                     ^^^
Quoted 7 lines

Old check.

    49			return 0;
    50	

regards,
dan carpenter

Thanks..
I suspect we should just remove the
if (!dev)
return

I should probably get rid of w1_bq27000_write as it is totally unused, and I need to hold a lock in w1_bq27000_read or I can get really bad things happening if two threads try to rad the status at the same time.

Ho hum.

Thanks,
NeilBrown