mvsas:Fix possible NULL pointer deference in mvs_dev_found_notify
Quoted 8 lines · Nicholas Krause
This adds properly checking after the call to
mvs_find_dev_mvidue to this function being able to return a NULL pointer and if this does arise we will deference it inmvs_alloc_devdue to this function never checking if a NULL pointer is given as it's input argument.
v2 - Fix NULL pointer deferenece in error path by callingspin_unlock_irqrestoreon the now NULL pointer, as returned bymvs_find_dev_mvi.
Hi Nicholas,
You mention v2 here but this is [PATCH] and not [PATCH v2]. Is this the first version of the patch or second?
Quoted 3 lines
Signed-off-by Nicholas Krause <[email protected]>---
If the "v2 -" comments are part of the review and not of the git commit message it is better to place it here. Between the "---" and the diff.
This is because when the maintainer applies the patch this section will be truncated, and it won't show in the git log.
Quoted 20 lines
drivers/scsi/mvsas/mv_sas.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/scsi/mvsas/mv_sas.c +4
-0@@ -1191,6 +1191,10 @@ int mvs_dev_found_notify(struct domain_device *dev, int lock)struct mvs_device *mvi_device; mvi =mvs_find_dev_mvi (dev); +if (!mvi) { + res =-1 ; + goto found_null; + }if (lock)spin_lock_irqsave (&mvi->lock, flags);
drivers/scsi/mvsas/mv_sas.c int mvs_dev_found_notify(struct domain_device *dev, int lock) · line 1240
Quoted 7 lines
drivers/scsi/mvsas/mv_sas.c +1
-0@@ -1230,6 +1234,7 @@ int mvs_dev_found_notify(struct domain_device *dev, int lock) found_out:if (lock)spin_unlock_irqrestore (&mvi->lock, flags); +found_null:return res; }
If the goto is just going to return, why not do a return directly instead?
if (!mvi)
return -1;
Thanks for the patch,
Luis