diff options
author | Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> | 2014-05-18 18:12:26 +0200 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2014-06-19 15:29:51 +0200 |
commit | eaa015d2bfc85dcabb44184b6ef826361b993c4b (patch) | |
tree | 044ab3f914b30c090b29a00075f8ef21f012a30c | |
parent | 305af08c5398bab6c7029da53eb15d85a53eef0e (diff) | |
download | linux-eaa015d2bfc85dcabb44184b6ef826361b993c4b.tar.bz2 |
scsi: mvsas: mv_sas.c: Fix for possible null pointer dereference
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r-- | drivers/scsi/mvsas/mv_sas.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c index 6c1f223a8e1d..ac52f7c99513 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; |