staging: lustre: fix potential NULL pointer dereference
authorMichal Nazarewicz <mina86@mina86.com>
Fri, 29 Nov 2013 17:10:59 +0000 (18:10 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 3 Dec 2013 17:03:20 +0000 (09:03 -0800)
The rest of the code seem to imply that rmf_dumper may indeed be
NULL.  Change the code so that dumping is not even considered if
rmf_dumper callback is not set.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/ptlrpc/layout.c

index eee88746e9d27fd872acf52d1953e333e987af06..dfcb410fe485fca73de833b68a765bff515a14aa 100644 (file)
@@ -1882,8 +1882,11 @@ swabber_dumper_helper(struct req_capsule *pill,
        else
                do_swab = 0;
 
+       if (!field->rmf_dumper)
+               dump = 0;
+
        if (!(field->rmf_flags & RMF_F_STRUCT_ARRAY)) {
-               if (dump && field->rmf_dumper) {
+               if (dump) {
                        CDEBUG(D_RPCTRACE, "Dump of %sfield %s follows\n",
                               do_swab ? "unswabbed " : "", field->rmf_name);
                        field->rmf_dumper(value);
@@ -1909,7 +1912,7 @@ swabber_dumper_helper(struct req_capsule *pill,
        for (p = value, i = 0, n = len / field->rmf_size;
             i < n;
             i++, p += field->rmf_size) {
-               if (dump && field->rmf_dumper) {
+               if (dump) {
                        CDEBUG(D_RPCTRACE, "Dump of %sarray field %s, "
                               "element %d follows\n",
                               do_swab ? "unswabbed " : "", field->rmf_name, i);
@@ -1918,7 +1921,7 @@ swabber_dumper_helper(struct req_capsule *pill,
                if (!do_swab)
                        continue;
                swabber(p);
-               if (dump && field->rmf_dumper) {
+               if (dump) {
                        CDEBUG(D_RPCTRACE, "Dump of swabbed array field %s, "
                               "element %d follows\n", field->rmf_name, i);
                        field->rmf_dumper(value);