Skip to contentSkip to conversation

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

PATCH Applied Dan Carpenter 2 participants 2 messages Nov 10, 2015 – Nov 12, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

drivers/message/fusion/mptctl.c +4 -0
index fc73937..02b5f69 100644
@@ -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;
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Dan" = Dan Carpenter <[email protected]> writes:

Dan> There is a static checker warning here because "bytes" is Dan> controlled by the user and we cap the upper bound with min() but Dan> allow negatives. Negative bytes will result in some nasty warning Dan> messages but are not super harmful. Anyway, no one needs negative Dan> bytes so let's just check for it and return NULL.

Applied.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering