public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Cc: Oleg Drokin <oleg.drokin@intel.com>,
	Andreas Dilger <andreas.dilger@intel.com>,
	Julia Lawall <Julia.Lawall@lip6.fr>,
	Greg Donald <gdonald@gmail.com>,
	"John L. Hammond" <john.hammond@intel.com>,
	Andriy Skulysh <Andriy_Skulysh@xyratex.com>,
	Fabian Frederick <fabf@skynet.be>,
	James Simmons <uja.ornl@gmail.com>,
	HPDD-discuss@ml01.01.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: lustre: lustre: obdclass: lprocfs_status.c: Fix for possible null pointer dereference
Date: Sun, 14 Dec 2014 14:39:53 -0800	[thread overview]
Message-ID: <20141214223953.GA4168@kroah.com> (raw)
In-Reply-To: <1418596582-24557-1-git-send-email-rickard_strandqvist@spectrumdigital.se>

On Sun, Dec 14, 2014 at 11:36:22PM +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 <rickard_strandqvist@spectrumdigital.se>
> ---
>  .../lustre/lustre/obdclass/lprocfs_status.c        |   20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> index 61e04af..4a7891a 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> @@ -1897,17 +1897,15 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count,
>  	}
>  
>  	units = 1;
> -	switch (*end) {
> -	case 'p': case 'P':
> -		units <<= 10;
> -	case 't': case 'T':
> -		units <<= 10;
> -	case 'g': case 'G':
> -		units <<= 10;
> -	case 'm': case 'M':
> -		units <<= 10;
> -	case 'k': case 'K':
> -		units <<= 10;
> +	if (end) {
> +		switch (*end) {
> +		case 'p': case 'P':
> +		case 't': case 'T':
> +		case 'g': case 'G':
> +		case 'm': case 'M':
> +		case 'k': case 'K':
> +			units <<= 10;
> +		}

You know you just changed the logic in the code, right?

Why?  Have you tested this?

greg k-h

  reply	other threads:[~2014-12-14 22:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-14 22:36 [PATCH] staging: lustre: lustre: obdclass: lprocfs_status.c: Fix for possible null pointer dereference Rickard Strandqvist
2014-12-14 22:39 ` Greg Kroah-Hartman [this message]
2014-12-14 22:43   ` Rickard Strandqvist
  -- strict thread matches above, loose matches on Subject: below --
2014-12-14 22:52 Rickard Strandqvist
2014-12-15  1:51 ` Joe Perches
2014-12-15 22:23   ` Rickard Strandqvist
2014-12-15 23:53     ` Joe Perches
2014-12-16  9:27     ` Dan Carpenter
2014-12-16  4:40 ` Chris Rorvick

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=20141214223953.GA4168@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=Andriy_Skulysh@xyratex.com \
    --cc=HPDD-discuss@ml01.01.org \
    --cc=Julia.Lawall@lip6.fr \
    --cc=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=fabf@skynet.be \
    --cc=gdonald@gmail.com \
    --cc=john.hammond@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg.drokin@intel.com \
    --cc=rickard_strandqvist@spectrumdigital.se \
    --cc=uja.ornl@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