Commit 3959d0cb authored by Oleg Drokin's avatar Oleg Drokin Committed by Greg Kroah-Hartman

staging/lustre/ptlrpc: Fix potential NULL pointer dereference

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: default avatarSebastien Buisson <sebastien.buisson@bull.net>
Reviewed-on: http://review.whamcloud.com/7827
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4049Reviewed-by: default avatarJohn L. Hammond <john.hammond@intel.com>
Reviewed-by: default avatarjacques-Charles Lafoucriere <jacques-charles.lafoucriere@cea.fr>
Signed-off: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 38bbb63d
...@@ -367,9 +367,11 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, ...@@ -367,9 +367,11 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
if (rc) if (rc)
return rc; return rc;
magic = le32_to_cpu(lmm->lmm_magic); magic = le32_to_cpu(lmm->lmm_magic);
pattern = le32_to_cpu(lmm->lmm_pattern);
} else { } else {
magic = LOV_MAGIC; magic = LOV_MAGIC;
stripe_count = lov_get_stripecnt(lov, magic, 0); 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 */ /* 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, ...@@ -384,7 +386,6 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
return 0; return 0;
} }
pattern = le32_to_cpu(lmm->lmm_pattern);
lsm_size = lov_alloc_memmd(lsmp, stripe_count, pattern, magic); lsm_size = lov_alloc_memmd(lsmp, stripe_count, pattern, magic);
if (lsm_size < 0) if (lsm_size < 0)
return lsm_size; return lsm_size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment