Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1371106

[PATCH 14/18] staging: lustre: fix 'NULL pointer dereference' errors

From James Simmons <jsimmons@infradead.org>
Newsgroups linux.kernel
Subject [PATCH 14/18] staging: lustre: fix 'NULL pointer dereference' errors
Date 2016-04-05 03:50 +0200
Message-ID <rkoi1-3Gi-69@gated-at.bofh.it> (permalink)
References <rkohY-3Gi-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Sebastien Buisson <sbuisson@ddn.com>

Fix 'NULL pointer dereference' defects found by Coverity version
6.5.0:
Dereference after null check (FORWARD_NULL)
For instance, Passing null pointer to a function which dereferences
it.
Dereference before null check (REVERSE_INULL)
Null-checking variable suggests that it may be null, but it has
already been dereferenced on all paths leading to the check.
Dereference null return value (NULL_RETURNS)

Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Signed-off-by: James Nunez <james.a.nunez@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3042
Reviewed-on: http://review.whamcloud.com/5868
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 drivers/staging/lustre/lustre/llite/dir.c  |   10 ++++++----
 drivers/staging/lustre/lustre/lov/lov_io.c |    3 ++-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c
index 41481cc..7251bef 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -612,15 +612,16 @@ static int ll_readdir(struct file *filp, struct dir_context *ctx)
 	struct inode		*inode	= file_inode(filp);
 	struct ll_file_data	*lfd	= LUSTRE_FPRIVATE(filp);
 	struct ll_sb_info	*sbi	= ll_i2sbi(inode);
+	__u64 pos = lfd ? lfd->lfd_pos : 0;
 	int			hash64	= sbi->ll_flags & LL_SBI_64BIT_HASH;
 	int			api32	= ll_need_32bit_api(sbi);
 	int			rc;
 
 	CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) pos %lu/%llu 32bit_api %d\n",
 	       inode->i_ino, inode->i_generation,
-	       inode, (unsigned long)lfd->lfd_pos, i_size_read(inode), api32);
+	       inode, (unsigned long)pos, i_size_read(inode), api32);
 
-	if (lfd->lfd_pos == MDS_DIR_END_OFF) {
+	if (pos == MDS_DIR_END_OFF) {
 		/*
 		 * end-of-file.
 		 */
@@ -628,9 +629,10 @@ static int ll_readdir(struct file *filp, struct dir_context *ctx)
 		goto out;
 	}
 
-	ctx->pos = lfd->lfd_pos;
+	ctx->pos = pos;
 	rc = ll_dir_read(inode, ctx);
-	lfd->lfd_pos = ctx->pos;
+	if (lfd)
+		lfd->lfd_pos = ctx->pos;
 	if (ctx->pos == MDS_DIR_END_OFF) {
 		if (api32)
 			ctx->pos = LL_DIR_END_OFF_32BIT;
diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c
index 4151237..0b59393 100644
--- a/drivers/staging/lustre/lustre/lov/lov_io.c
+++ b/drivers/staging/lustre/lustre/lov/lov_io.c
@@ -276,10 +276,11 @@ struct lov_io_sub *lov_page_subio(const struct lu_env *env, struct lov_io *lio,
 static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio,
 			     struct cl_io *io)
 {
-	struct lov_stripe_md *lsm = lio->lis_object->lo_lsm;
+	struct lov_stripe_md *lsm;
 	int result;
 
 	LASSERT(lio->lis_object);
+	lsm = lio->lis_object->lo_lsm;
 
 	/*
 	 * Need to be optimized, we can't afford to allocate a piece of memory
-- 
1.7.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/18] fill in missing patches present in 2.4.92 version James Simmons <jsimmons@infradead.org> - 2016-04-05 03:50 +0200
  [PATCH 05/18] staging: lustre: libcfs: make D_HSM a unique value James Simmons <jsimmons@infradead.org> - 2016-04-05 03:50 +0200
  [PATCH 13/18] staging: lustre: hsm: Add CLF_RENAME_LAST flag James Simmons <jsimmons@infradead.org> - 2016-04-05 03:50 +0200
  [PATCH 16/18] staging: lustre: hsm: Add support to drop all pages for ll_data_version James Simmons <jsimmons@infradead.org> - 2016-04-05 03:50 +0200
  [PATCH 04/18] staging: lustre: libcfs: create array of debug names James Simmons <jsimmons@infradead.org> - 2016-04-05 03:50 +0200
  [PATCH 15/18] staging: lustre: llite: cancel open lock before closing file James Simmons <jsimmons@infradead.org> - 2016-04-05 03:50 +0200
  [PATCH 03/18] staging: lustre: libcfs: remove userland comments in libcfs_debug.h James Simmons <jsimmons@infradead.org> - 2016-04-05 03:50 +0200
  [PATCH 12/18] staging: lustre: mdc: document mdc_rpc_lock James Simmons <jsimmons@infradead.org> - 2016-04-05 03:50 +0200
  [PATCH 02/18] staging: lustre: llite: use 64bits flags in ll_lov_setea() James Simmons <jsimmons@infradead.org> - 2016-04-05 03:50 +0200
  [PATCH 08/18] staging: lustre: hsm: copy start error should set HP_FLAG_COMPLETED James Simmons <jsimmons@infradead.org> - 2016-04-05 03:50 +0200
  [PATCH 11/18] staging: lustre: llite: Delaying creation of client side proc entries. James Simmons <jsimmons@infradead.org> - 2016-04-05 03:50 +0200
  [PATCH 01/18] staging: lustre: ldlm: fix 'deadcode' errors James Simmons <jsimmons@infradead.org> - 2016-04-05 03:50 +0200
  [PATCH 17/18] staging: lustre: fix 'no effect' errors James Simmons <jsimmons@infradead.org> - 2016-04-05 03:50 +0200
  [PATCH 07/18] staging: lustre: hsm: rename hai_zero() HSM function James Simmons <jsimmons@infradead.org> - 2016-04-05 03:50 +0200
  [PATCH 10/18] staging: lustre: llite: reset writeback index in ll_writepages James Simmons <jsimmons@infradead.org> - 2016-04-05 03:50 +0200
  [PATCH 06/18] staging: lustre: hsm: Fix lu_ref for lease handle James Simmons <jsimmons@infradead.org> - 2016-04-05 03:50 +0200
  [PATCH 14/18] staging: lustre: fix 'NULL pointer dereference' errors James Simmons <jsimmons@infradead.org> - 2016-04-05 03:50 +0200
  [PATCH 09/18] staging: lustre: lov: Get the correct address of lmm_objects James Simmons <jsimmons@infradead.org> - 2016-04-05 04:00 +0200

csiph-web