Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751165AbaLOXHm (ORCPT ); Mon, 15 Dec 2014 18:07:42 -0500 Received: from mail-lb0-f178.google.com ([209.85.217.178]:52511 "EHLO mail-lb0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750777AbaLOXHl (ORCPT ); Mon, 15 Dec 2014 18:07:41 -0500 MIME-Version: 1.0 In-Reply-To: <20141215102502.GB4856@mwanda> References: <1418596638-24646-1-git-send-email-rickard_strandqvist@spectrumdigital.se> <20141215102502.GB4856@mwanda> From: Rickard Strandqvist Date: Tue, 16 Dec 2014 00:07:19 +0100 Message-ID: Subject: Re: [PATCH] staging: lustre: lustre: osc: lproc_osc.c: Fix for possible null pointer dereference To: Dan Carpenter Cc: Oleg Drokin , Andreas Dilger , devel@driverdev.osuosl.org, Greg Kroah-Hartman , Brilliantov Kirill Vladimirovich , "linux-kernel@vger.kernel.org" , HPDD-discuss@ml01.01.org, Greg Donald Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dan Quite right! Had to try it. Do nothing then? But you must agree that it is still ugly and confusing code. Kind regards Rickard Strandqvist 2014-12-15 11:25 GMT+01:00 Dan Carpenter : > On Sun, Dec 14, 2014 at 11:37:18PM +0100, Rickard Strandqvist wrote: >> There is otherwise a risk of a possible null pointer dereference. >> >> Was largely found by using a static code analysis program called cppcheck. >> >> Signed-off-by: Rickard Strandqvist >> --- >> drivers/staging/lustre/lustre/osc/lproc_osc.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c >> index 9f719bc..9ba6293 100644 >> --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c >> +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c >> @@ -237,13 +237,15 @@ static ssize_t osc_cur_grant_bytes_seq_write(struct file *file, const char *buff >> size_t count, loff_t *off) >> { >> struct obd_device *obd = ((struct seq_file *)file->private_data)->private; >> - struct client_obd *cli = &obd->u.cli; >> + struct client_obd *cli; > > This isn't really a dereference. You're just getting the address of > obd->u.cli. So if obd is NULL then it won't crash. > > regards, > dan carpenter > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/