]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging/lustre/ptlrpc: Fix potential NULL pointer dereference
authorOleg Drokin <green@linuxhacker.ru>
Sat, 16 May 2015 07:38:33 +0000 (03:38 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 31 May 2015 00:29:45 +0000 (09:29 +0900)
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/lov/lov_pack.c

index 5356d532417639de6fc86bfdabb5d016d488e6ea..92b9ffece4a088b9e1fccce28b14d8dc888ba55f 100644 (file)
@@ -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;