staging: lustre: prevent underflows in lnet_parse_reply()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 1 Apr 2015 08:13:03 +0000 (11:13 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Apr 2015 09:07:33 +0000 (11:07 +0200)
I don't know if "hdr->payload_length;" can really be negative, but if so
then we shouldn't allow it.  Do the comparison as an unsigned.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lnet/lnet/lib-move.c

index 0f53c76..c2fb70e 100644 (file)
@@ -1530,7 +1530,7 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg)
        LASSERT(md->md_offset == 0);
 
        rlength = hdr->payload_length;
-       mlength = min_t(int, rlength, md->md_length);
+       mlength = min_t(uint, rlength, md->md_length);
 
        if (mlength < rlength &&
            (md->md_options & LNET_MD_TRUNCATE) == 0) {