public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: lustre: lustre: obdclass: lprocfs_status.c:  Fix for possible null pointer dereference
@ 2014-12-14 22:36 Rickard Strandqvist
  2014-12-14 22:39 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 9+ messages in thread
From: Rickard Strandqvist @ 2014-12-14 22:36 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger
  Cc: Rickard Strandqvist, Greg Kroah-Hartman, Julia Lawall,
	Greg Donald, John L. Hammond, Andriy Skulysh, Fabian Frederick,
	James Simmons, HPDD-discuss, devel, linux-kernel

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;
+		}
 	}
 	/* Specified units override the multiplier */
 	if (units)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread
* [PATCH] staging: lustre: lustre: obdclass: lprocfs_status.c:  Fix for possible null pointer dereference
@ 2014-12-14 22:52 Rickard Strandqvist
  2014-12-15  1:51 ` Joe Perches
  2014-12-16  4:40 ` Chris Rorvick
  0 siblings, 2 replies; 9+ messages in thread
From: Rickard Strandqvist @ 2014-12-14 22:52 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger
  Cc: Rickard Strandqvist, Greg Kroah-Hartman, Julia Lawall,
	Greg Donald, John L. Hammond, Andriy Skulysh, Fabian Frederick,
	James Simmons, HPDD-discuss, devel, linux-kernel

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        |   24 +++++++++++---------
 1 file changed, 13 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..5227324 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -1897,17 +1897,19 @@ 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':
+			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;
+		}
 	}
 	/* Specified units override the multiplier */
 	if (units)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-12-16  9:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox