lkml.org 
[lkml]   [2015]   [Jan]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [HPDD-discuss] [PATCH] staging: lustre: include: lustre_update.h: Fix for possible null pointer dereference
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);
> }
>



\
 
 \ /
  Last update: 2015-01-29 21:01    [W:3.101 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site