mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: green@linuxhacker.ru
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org,
	Andreas Dilger <andreas.dilger@intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Oleg Drokin <green@linuxhacker.ru>,
	Sebastien Buisson <sebastien.buisson@bull.net>
Subject: [PATCH 3/4] staging/lustre/ptlrpc: Fix potential NULL pointer dereference
Date: Sat, 16 May 2015 03:38:33 -0400	[thread overview]
Message-ID: <1431761914-20677-4-git-send-email-green@linuxhacker.ru> (raw)
In-Reply-To: <1431761914-20677-1-git-send-email-green@linuxhacker.ru>

From: Oleg Drokin <green@linuxhacker.ru>

In lov_unpackmd() there's this strange bit of code where we first try
to look inside of lmm striping pattern for it's type, and then
we check if the pattern is NULL which cannot be right.
Move the check under if (lmm) branch so that it's safe.

Found by Coverity version 6.6.1

Signed-off-by: Sebastien Buisson <sebastien.buisson@bull.net>
Reviewed-on: http://review.whamcloud.com/7827
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4049
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: jacques-Charles Lafoucriere <jacques-charles.lafoucriere@cea.fr>
Signed-off: Oleg Drokin <oleg.drokin@intel.com>
---
 drivers/staging/lustre/lustre/lov/lov_pack.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c
index 5356d53..92b9ffe 100644
--- a/drivers/staging/lustre/lustre/lov/lov_pack.c
+++ b/drivers/staging/lustre/lustre/lov/lov_pack.c
@@ -367,9 +367,11 @@ int lov_unpackmd(struct obd_export *exp,  struct lov_stripe_md **lsmp,
 		if (rc)
 			return rc;
 		magic = le32_to_cpu(lmm->lmm_magic);
+		pattern = le32_to_cpu(lmm->lmm_pattern);
 	} else {
 		magic = LOV_MAGIC;
 		stripe_count = lov_get_stripecnt(lov, magic, 0);
+		pattern = LOV_PATTERN_RAID0;
 	}
 
 	/* If we aren't passed an lsmp struct, we just want the size */
@@ -384,7 +386,6 @@ int lov_unpackmd(struct obd_export *exp,  struct lov_stripe_md **lsmp,
 		return 0;
 	}
 
-	pattern = le32_to_cpu(lmm->lmm_pattern);
 	lsm_size = lov_alloc_memmd(lsmp, stripe_count, pattern, magic);
 	if (lsm_size < 0)
 		return lsm_size;
-- 
2.1.0


  parent reply	other threads:[~2015-05-16  7:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-16  7:38 [PATCH 0/4] Few lustre fixes and cleanups green
2015-05-16  7:38 ` [PATCH 1/4] staging/lustre: Only set INTERRUPTIBLE state before calling schedule green
2015-05-16  7:38 ` [PATCH 2/4] staging/lustre/ptlrpc: Fix wrong indenting in plain_authorize() green
2015-05-16  7:38 ` green [this message]
2015-05-16  7:38 ` [PATCH 4/4] staging/lustre/llite: Fix wrong identing in ll_setxattr_common green

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=1431761914-20677-4-git-send-email-green@linuxhacker.ru \
    --to=green@linuxhacker.ru \
    --cc=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sebastien.buisson@bull.net \
    /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

all inboxes | Powered by JetHome®