public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frank Zago <fzago@cray.com>
To: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>,
	Oleg Drokin <oleg.drokin@intel.com>,
	Andreas Dilger <andreas.dilger@intel.com>
Cc: <HPDD-discuss@ml01.01.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	<devel@driverdev.osuosl.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [HPDD-discuss] [PATCH] staging: lustre: include: lustre_update.h: Fix for possible null pointer dereference
Date: Thu, 29 Jan 2015 13:40:23 -0600	[thread overview]
Message-ID: <54CA8CA7.2070403@cray.com> (raw)
In-Reply-To: <1422557229-3484-1-git-send-email-rickard_strandqvist@spectrumdigital.se>

On 01/29/2015 12:47 PM, Rickard Strandqvist wrote:
> Fix a possible null pointer dereference, there is
> otherwise a risk of a possible null pointer dereference.
>
> This was found using a static code analysis program called cppcheck
>
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
>   drivers/staging/lustre/lustre/include/lustre_update.h |    4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/lustre/lustre/include/lustre_update.h b/drivers/staging/lustre/lustre/include/lustre_update.h
> index 84defce..00e1361 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_update.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_update.h
> @@ -165,12 +165,14 @@ static inline int update_get_reply_buf(struct update_reply *reply, void **buf,
>   	int  result;
>
>   	ptr = update_get_buf_internal(reply, index, &size);
> +
> +	LASSERT((ptr != NULL && size >= sizeof(int)));

Now size is tested before result. So it could assert if result < 0, 
while the function would have returned before.

> +
>   	result = *(int *)ptr;
>
>   	if (result < 0)
>   		return result;
>
> -	LASSERT((ptr != NULL && size >= sizeof(int)));
>   	*buf = ptr + sizeof(int);
>   	return size - sizeof(int);
>   }
>


  reply	other threads:[~2015-01-29 19:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-29 18:47 [PATCH] staging: lustre: include: lustre_update.h: Fix for possible null pointer dereference Rickard Strandqvist
2015-01-29 19:40 ` Frank Zago [this message]
2015-01-29 19:47   ` [HPDD-discuss] " Rickard Strandqvist
2015-01-29 19:49     ` Frank Zago
2015-01-29 20:26       ` Drokin, Oleg

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=54CA8CA7.2070403@cray.com \
    --to=fzago@cray.com \
    --cc=HPDD-discuss@ml01.01.org \
    --cc=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg.drokin@intel.com \
    --cc=rickard_strandqvist@spectrumdigital.se \
    /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