Bläddra i källkod

mptfusion: don't allow negative bytes in kbuf_alloc_2_sgl()

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>
Dan Carpenter 9 år sedan
förälder
incheckning
491212014e
1 ändrade filer med 4 tillägg och 0 borttagningar
  1. 4 0
      drivers/message/fusion/mptctl.c

+ 4 - 0
drivers/message/fusion/mptctl.c

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