From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757000AbbA2Snx (ORCPT ); Thu, 29 Jan 2015 13:43:53 -0500 Received: from mail-lb0-f171.google.com ([209.85.217.171]:53194 "EHLO mail-lb0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751307AbbA2Snu (ORCPT ); Thu, 29 Jan 2015 13:43:50 -0500 From: Rickard Strandqvist To: Oleg Drokin , Andreas Dilger Cc: Rickard Strandqvist , Greg Kroah-Hartman , HPDD-discuss@ml01.01.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] staging: lustre: include: lustre_update.h: Fix for possible null pointer dereference Date: Thu, 29 Jan 2015 19:47:09 +0100 Message-Id: <1422557229-3484-1-git-send-email-rickard_strandqvist@spectrumdigital.se> X-Mailer: git-send-email 1.7.10.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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))); + result = *(int *)ptr; if (result < 0) return result; - LASSERT((ptr != NULL && size >= sizeof(int))); *buf = ptr + sizeof(int); return size - sizeof(int); } -- 1.7.10.4