diff mbox

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

Message ID 20151110221524.GB30281@mwanda (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Dan Carpenter Nov. 10, 2015, 10:15 p.m. UTC
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>

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Martin K. Petersen Nov. 12, 2015, 1:59 a.m. UTC | #1
>>>>> "Dan" == Dan Carpenter <dan.carpenter@oracle.com> 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.
diff mbox

Patch

diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index fc73937..02b5f69 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/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		 sg_spill = MAX_FRAGS_SPILL1;
 	int		 dir;
+
+	if (bytes < 0)
+		return NULL;
+
 	/* initialization */
 	*frags = 0;
 	*blp = NULL;