2006-03-09 11:02:10

by Adrian Bunk

[permalink] [raw]
Subject: drivers/scsi/sata_vsc.c: inconsistent NULL checking

The Coverity checker found this inconsistent NULL checking recently
introduced by the following commit:

2ae5b30ff08cee422c7f6388a759f7
Author: Dan Williams <[email protected]>
[PATCH] Necessary evil to get sata_vsc to initialize with Intel iq3124h hba


In function vsc_sata_interrupt():

err_status = ap ? vsc_sata_scr_read(ap, SCR_ERROR) : 0;
vsc_sata_scr_write(ap, SCR_ERROR, err_status);


vsc_sata_scr_write() always dereferences ap
(since SCR_ERROR < SCR_CONTROL).

Checking for NULL in one line and unconditionally dereferencing the
variable in the next line can't be right.

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed


2006-03-09 19:44:47

by Dan Williams

[permalink] [raw]
Subject: Re: drivers/scsi/sata_vsc.c: inconsistent NULL checking

On 3/9/06, Adrian Bunk <[email protected]> wrote:
> The Coverity checker found this inconsistent NULL checking recently
> introduced by the following commit:
>
> 2ae5b30ff08cee422c7f6388a759f7
> Author: Dan Williams <[email protected]>
> [PATCH] Necessary evil to get sata_vsc to initialize with Intel iq3124h hba
>
>
> In function vsc_sata_interrupt():
>
> err_status = ap ? vsc_sata_scr_read(ap, SCR_ERROR) : 0;
> vsc_sata_scr_write(ap, SCR_ERROR, err_status);
>
>
> vsc_sata_scr_write() always dereferences ap
> (since SCR_ERROR < SCR_CONTROL).
>
> Checking for NULL in one line and unconditionally dereferencing the
> variable in the next line can't be right.
>

The attached patch cleans up the code, and adds GD31244 to the driver
description in drivers/scsi/Kconfig.

Dan


Attachments:
(No filename) (805.00 B)
sata_vsc_clean_up.patch (3.39 kB)
Download all attachments

2006-03-09 20:41:42

by Dan Williams

[permalink] [raw]
Subject: Re: drivers/scsi/sata_vsc.c: inconsistent NULL checking

>
> The attached patch cleans up the code, and adds GD31244 to the driver
> description in drivers/scsi/Kconfig.
>

Joe Perches suggested some coding style changes. Here is version 2.

Dan


Attachments:
(No filename) (190.00 B)
sata_vsc_clean_up-v2.patch (3.36 kB)
Download all attachments

2006-03-22 03:08:58

by Jeff Garzik

[permalink] [raw]
Subject: Re: drivers/scsi/sata_vsc.c: inconsistent NULL checking

Dan Williams wrote:
>>The attached patch cleans up the code, and adds GD31244 to the driver
>>description in drivers/scsi/Kconfig.

> Joe Perches suggested some coding style changes. Here is version 2.

Applied. When resending patches, please continue to follow the standard
patch submission format, particularly #2, #5 and #6:
http://linux.yyz.us/patch-format.html

Regards,

Jeff