]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mptfusion: don't allow negative bytes in kbuf_alloc_2_sgl()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 10 Nov 2015 22:15:24 +0000 (01:15 +0300)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 12 Nov 2015 01:58:06 +0000 (20:58 -0500)
There is a static checker warning here because "bytes" is controlled by
the user and we cap the upper bound with min() but allow negatives.
Negative bytes will result in some nasty warning messages but are not
super harmful.  Anyway, no one needs negative bytes so let's just check
for it and return NULL.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/message/fusion/mptctl.c

index fc73937290812df292d9654ed43ec19f40497edf..02b5f69e1a423f2dd44eede58aaf010d55f3c9d9 100644 (file)
@@ -1038,6 +1038,10 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, int sge_offset, int *frags,
        int              i, buflist_ent;
        int              sg_spill = MAX_FRAGS_SPILL1;
        int              dir;
+
+       if (bytes < 0)
+               return NULL;
+
        /* initialization */
        *frags = 0;
        *blp = NULL;