* [PATCH] scsi: mvsas: mv_sas.c: Fix for possible null pointer dereference
@ 2014-05-18 16:12 Rickard Strandqvist
2014-05-28 11:27 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Rickard Strandqvist @ 2014-05-18 16:12 UTC (permalink / raw)
To: James E.J. Bottomley, Rickard Strandqvist
Cc: Jiri Kosina, Randy Dunlap, Masanari Iida, 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/mvsas/mv_sas.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
index 6c1f223..ac52f7c 100644
--- a/drivers/scsi/mvsas/mv_sas.c
+++ b/drivers/scsi/mvsas/mv_sas.c
@@ -1344,19 +1344,23 @@ void mvs_dev_gone_notify(struct domain_device *dev)
{
unsigned long flags = 0;
struct mvs_device *mvi_dev = dev->lldd_dev;
- struct mvs_info *mvi = mvi_dev->mvi_info;
-
- spin_lock_irqsave(&mvi->lock, flags);
+ struct mvs_info *mvi;
- if (mvi_dev) {
- mv_dprintk("found dev[%d:%x] is gone.\n",
- mvi_dev->device_id, mvi_dev->dev_type);
- mvs_release_task(mvi, dev);
- mvs_free_reg_set(mvi, mvi_dev);
- mvs_free_dev(mvi_dev);
- } else {
+ if (!mvi_dev) {
mv_dprintk("found dev has gone.\n");
+ return;
}
+
+ mvi = mvi_dev->mvi_info;
+
+ spin_lock_irqsave(&mvi->lock, flags);
+
+ mv_dprintk("found dev[%d:%x] is gone.\n",
+ mvi_dev->device_id, mvi_dev->dev_type);
+ mvs_release_task(mvi, dev);
+ mvs_free_reg_set(mvi, mvi_dev);
+ mvs_free_dev(mvi_dev);
+
dev->lldd_dev = NULL;
mvi_dev->sas_device = NULL;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] scsi: mvsas: mv_sas.c: Fix for possible null pointer dereference
2014-05-18 16:12 [PATCH] scsi: mvsas: mv_sas.c: Fix for possible null pointer dereference Rickard Strandqvist
@ 2014-05-28 11:27 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2014-05-28 11:27 UTC (permalink / raw)
To: Rickard Strandqvist
Cc: James E.J. Bottomley, Jiri Kosina, Randy Dunlap, Masanari Iida,
linux-scsi, linux-kernel
On Sun, May 18, 2014 at 06:12:26PM +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.
>
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Looks good, although I'd love to know how a NULL dev could even happen
here.
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-28 11:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-18 16:12 [PATCH] scsi: mvsas: mv_sas.c: Fix for possible null pointer dereference Rickard Strandqvist
2014-05-28 11:27 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).