* [PATCH] scsi: pm8001: pm8001_hwi.c: Fix for possible null pointer dereference
@ 2014-05-18 16:14 Rickard Strandqvist
2014-05-28 11:28 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Rickard Strandqvist @ 2014-05-18 16:14 UTC (permalink / raw)
To: xjtuwjp, lindar_liu
Cc: Rickard Strandqvist, James E.J. Bottomley, linux-scsi,
linux-kernel
There is otherwise a risk of a possible null pointer dereference.
Was largely found by using a static code analysis program called cppcheck.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
drivers/scsi/pm8001/pm8001_hwi.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index a97be01..60a988c 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -4367,7 +4367,8 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
}
dir = data_dir_flags[task->data_dir] << 8;
sata_cmd.tag = cpu_to_le32(tag);
- sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id);
+ if(pm8001_ha_dev)
+ sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id);
sata_cmd.data_len = cpu_to_le32(task->total_xfer_len);
sata_cmd.ncqtag_atap_dir_m =
cpu_to_le32(((ncg_tag & 0xff)<<16)|((ATAP & 0x3f) << 10) | dir);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: pm8001: pm8001_hwi.c: Fix for possible null pointer dereference
2014-05-18 16:14 [PATCH] scsi: pm8001: pm8001_hwi.c: Fix for possible null pointer dereference Rickard Strandqvist
@ 2014-05-28 11:28 ` Christoph Hellwig
2014-05-28 11:38 ` Tomas Henzl
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2014-05-28 11:28 UTC (permalink / raw)
To: Rickard Strandqvist
Cc: xjtuwjp, lindar_liu, James E.J. Bottomley, linux-scsi,
linux-kernel
On Sun, May 18, 2014 at 06:14:00PM +0200, Rickard Strandqvist wrote:
> There is otherwise a risk of a possible null pointer dereference.
>
> Was largely found by using a static code analysis program called cppcheck.
I can't see how dev->lldd_dev would be NULL here.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: pm8001: pm8001_hwi.c: Fix for possible null pointer dereference
2014-05-28 11:28 ` Christoph Hellwig
@ 2014-05-28 11:38 ` Tomas Henzl
2014-05-29 23:05 ` Rickard Strandqvist
0 siblings, 1 reply; 4+ messages in thread
From: Tomas Henzl @ 2014-05-28 11:38 UTC (permalink / raw)
To: Christoph Hellwig, Rickard Strandqvist
Cc: xjtuwjp, lindar_liu, James E.J. Bottomley, linux-scsi,
linux-kernel
On 05/28/2014 01:28 PM, Christoph Hellwig wrote:
> On Sun, May 18, 2014 at 06:14:00PM +0200, Rickard Strandqvist wrote:
>> There is otherwise a risk of a possible null pointer dereference.
>>
>> Was largely found by using a static code analysis program called cppcheck.
> I can't see how dev->lldd_dev would be NULL here.
The analysis program likely can't know that, the reason for this report
it that dev->lldd_dev is tested for not being null several lines below -
http://lxr.free-electrons.com/source/drivers/scsi/pm8001/pm8001_hwi.c#L4447
So the other option is to remove this^ test.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: pm8001: pm8001_hwi.c: Fix for possible null pointer dereference
2014-05-28 11:38 ` Tomas Henzl
@ 2014-05-29 23:05 ` Rickard Strandqvist
0 siblings, 0 replies; 4+ messages in thread
From: Rickard Strandqvist @ 2014-05-29 23:05 UTC (permalink / raw)
To: Tomas Henzl
Cc: Christoph Hellwig, Wang Jinpu, lindar_liu, James E.J. Bottomley,
linux-scsi, linux-kernel@vger.kernel.org
Hi
Quite rightly, this is what cppcheck reacts.
Ok, I'll send a patch for that instead then.
Best regards
Rickard Strandqvist
2014-05-28 13:38 GMT+02:00 Tomas Henzl <thenzl@redhat.com>:
> On 05/28/2014 01:28 PM, Christoph Hellwig wrote:
>> On Sun, May 18, 2014 at 06:14:00PM +0200, Rickard Strandqvist wrote:
>>> There is otherwise a risk of a possible null pointer dereference.
>>>
>>> Was largely found by using a static code analysis program called cppcheck.
>> I can't see how dev->lldd_dev would be NULL here.
>
> The analysis program likely can't know that, the reason for this report
> it that dev->lldd_dev is tested for not being null several lines below -
> http://lxr.free-electrons.com/source/drivers/scsi/pm8001/pm8001_hwi.c#L4447
> So the other option is to remove this^ test.
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-05-29 23:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-18 16:14 [PATCH] scsi: pm8001: pm8001_hwi.c: Fix for possible null pointer dereference Rickard Strandqvist
2014-05-28 11:28 ` Christoph Hellwig
2014-05-28 11:38 ` Tomas Henzl
2014-05-29 23:05 ` Rickard Strandqvist
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox