* Re: [PATCH] mvsas:Fix possible NULL pointer deference in mvs_dev_found_notify [not found] <1467395018-12365-1-git-send-email-xerofoify@gmail.com> @ 2016-07-02 11:16 ` Luis de Bethencourt 0 siblings, 0 replies; 3+ messages in thread From: Luis de Bethencourt @ 2016-07-02 11:16 UTC (permalink / raw) To: Nicholas Krause, jejb Cc: martin.petersen, jthumshirn, tj, James.Bottomley, Wilfried.Weissmann, davispuh, linux-scsi, linux-kernel On 01/07/16 18:43, Nicholas Krause wrote: > This adds properly checking after the call to mvs_find_dev_mvi > due to this function being able to return a NULL pointer and if > this does arise we will deference it in mvs_alloc_dev due 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 calling > spin_unlock_irqrestore on the now NULL pointer, as returned > by mvs_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? > > Signed-off-by: Nicholas Krause <xerofoify@gmail.com> > --- 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. > drivers/scsi/mvsas/mv_sas.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c > index 83cd3ea..74f3954 100644 > --- a/drivers/scsi/mvsas/mv_sas.c > +++ b/drivers/scsi/mvsas/mv_sas.c > @@ -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); > @@ -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 ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <1457531917-568-1-git-send-email-xerofoify@gmail.com>]
* Re: [PATCH] mvsas:Fix possible NULL pointer deference in mvs_dev_found_notify [not found] <1457531917-568-1-git-send-email-xerofoify@gmail.com> @ 2016-03-09 20:33 ` Dāvis Mosāns 2016-03-10 1:18 ` Valdis.Kletnieks 0 siblings, 1 reply; 3+ messages in thread From: Dāvis Mosāns @ 2016-03-09 20:33 UTC (permalink / raw) To: Nicholas Krause Cc: James Bottomley, Johannes Thumshirn, luisbg, Wilfried.Weissmann, linux-scsi, linux-kernel 2016-03-09 15:58 GMT+02:00 Nicholas Krause <xerofoify@gmail.com>: > This adds properly checking after the call to mvs_find_dev_mvi > due to this function being able to return a NULL pointer and if > this does arise we will deference it in mvs_alloc_dev due to > this function never checking if a NULL pointer is given as > it's input argument. > > Signed-off-by: Nicholas Krause <xerofoify@gmail.com> > --- > drivers/scsi/mvsas/mv_sas.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c > index 83cd3ea..7afb248 100644 > --- a/drivers/scsi/mvsas/mv_sas.c > +++ b/drivers/scsi/mvsas/mv_sas.c > @@ -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_out; > + } > > if (lock) > spin_lock_irqsave(&mvi->lock, flags); > -- > 2.5.0 > It doesn't look right, if mvi will be NULL and lock will be set then at found_out: if (lock) spin_unlock_irqrestore(&mvi->lock, flags); there will be mvi dereference, besides spin_lock_irqsave wasn't even called. And without this patch dereference would happen on mvi->lock which is before use in mvs_alloc_dev About whether mvs_find_dev_mvi can return NULL it looks like it's possible, but I'm not sure if it practically happens. I guess it did hence patch. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mvsas:Fix possible NULL pointer deference in mvs_dev_found_notify 2016-03-09 20:33 ` Dāvis Mosāns @ 2016-03-10 1:18 ` Valdis.Kletnieks 0 siblings, 0 replies; 3+ messages in thread From: Valdis.Kletnieks @ 2016-03-10 1:18 UTC (permalink / raw) To: Dāvis Mosāns Cc: Nicholas Krause, James Bottomley, Johannes Thumshirn, luisbg, Wilfried.Weissmann, linux-scsi, linux-kernel [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 461 bytes --] On Wed, 09 Mar 2016 22:33:47 +0200, Dāvis Mosāns said: > About whether mvs_find_dev_mvi can return NULL it looks like it's possible, > but I'm not sure if it practically happens. I guess it did hence patch. Or the "bug" was found by incorrect code inspection. Nick has a history of submitting patches that are for either non-existent problems or don't deal with with the issue correctly - bad enough that he's not allowed to post to the linux-kernel list. [-- Attachment #2: Type: application/pgp-signature, Size: 848 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-07-02 11:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1467395018-12365-1-git-send-email-xerofoify@gmail.com>
2016-07-02 11:16 ` [PATCH] mvsas:Fix possible NULL pointer deference in mvs_dev_found_notify Luis de Bethencourt
[not found] <1457531917-568-1-git-send-email-xerofoify@gmail.com>
2016-03-09 20:33 ` Dāvis Mosāns
2016-03-10 1:18 ` Valdis.Kletnieks
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
Powered by JetHome