public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] mptfusion: don't allow negative bytes in kbuf_alloc_2_sgl()
@ 2015-11-10 22:15 Dan Carpenter
  2015-11-12  1:59 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2015-11-10 22:15 UTC (permalink / raw)
  To: Nagalakshmi Nandigama
  Cc: Praveen Krishnamoorthy, Sreekanth Reddy, Abhijit Mahajan,
	MPT-FusionLinux.pdl, linux-scsi, kernel-janitors

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>

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;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-12  1:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-10 22:15 [patch] mptfusion: don't allow negative bytes in kbuf_alloc_2_sgl() Dan Carpenter
2015-11-12  1:59 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox