All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roel Kluin <roel.kluin@gmail.com>
To: abjoglek@cisco.com
Cc: linux-scsi@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] remove redundant BUG_ON
Date: Mon, 22 Jun 2009 19:54:38 +0200	[thread overview]
Message-ID: <4A3FC55E.80108@gmail.com> (raw)

sg_count is unsigned. If negative, a wrap causes the second BUG_ON to trigger.

scsi_dma_map may return -ENOMEM, sg_count should be int to catch that.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Please use this one instead.

diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index eabf365..22a7cd5 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -260,7 +260,6 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic,
 	char msg[2];
 
 	if (sg_count) {
-		BUG_ON(sg_count < 0);
 		BUG_ON(sg_count > FNIC_MAX_SG_DESC_CNT);
 
 		/* For each SGE, create a device desc entry */
@@ -344,7 +343,7 @@ int fnic_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
 	struct fnic *fnic;
 	struct vnic_wq_copy *wq;
 	int ret;
-	u32 sg_count;
+	int sg_count;
 	unsigned long flags;
 	unsigned long ptr;
 

             reply	other threads:[~2009-06-22 15:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-22 17:54 Roel Kluin [this message]
2009-06-22 18:15 ` [PATCH] remove redundant BUG_ON Abhijeet Joglekar (abjoglek)
2009-06-22 23:06 ` [PATCH] fnic: remove redundant BUG_ONs and fix checks on unsigned Roel Kluin
  -- strict thread matches above, loose matches on Subject: below --
2009-06-22 17:43 [PATCH] remove redundant BUG_ON Roel Kluin
2009-06-22 16:02 ` Mike Christie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A3FC55E.80108@gmail.com \
    --to=roel.kluin@gmail.com \
    --cc=abjoglek@cisco.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.