mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luis de Bethencourt <luisbg@osg.samsung.com>
To: Nicholas Krause <xerofoify@gmail.com>, jejb@linux.vnet.ibm.com
Cc: martin.petersen@oracle.com, jthumshirn@suse.de, tj@kernel.org,
	James.Bottomley@HansenPartnership.com, Wilfried.Weissmann@gmx.at,
	davispuh@gmail.com, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mvsas:Fix possible NULL pointer deference in mvs_dev_found_notify
Date: Sat, 02 Jul 2016 12:16:24 +0100	[thread overview]
Message-ID: <5777A288.90608@osg.samsung.com> (raw)
In-Reply-To: <1467395018-12365-1-git-send-email-xerofoify@gmail.com>

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

       reply	other threads:[~2016-07-02 11:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1467395018-12365-1-git-send-email-xerofoify@gmail.com>
2016-07-02 11:16 ` Luis de Bethencourt [this message]
     [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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5777A288.90608@osg.samsung.com \
    --to=luisbg@osg.samsung.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=Wilfried.Weissmann@gmx.at \
    --cc=davispuh@gmail.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=jthumshirn@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=tj@kernel.org \
    --cc=xerofoify@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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