All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nishanth Aravamudan <nacc@us.ibm.com>
To: dgilbert@interlog.com
Cc: James.Bottomley@SteelEye.com, linux-scsi@vger.kernel.org
Subject: [PATCH] scsi_debug: dev_size_mb <= 0 fix
Date: Thu, 5 Aug 2004 14:35:47 -0700	[thread overview]
Message-ID: <20040805213547.GA3856@us.ibm.com> (raw)

Hi,

While working on getting 10000 scsi_debug disks working simultaneously,
I came across a problem with the driver. According to the webpage,

``All simulated dummy devices share the same RAM. If a value of 0 or
less is given then dev_size_mb is forced to 1 so 1 MB of RAM is used.''

However, when I sent in dev_size_mb=0, the module would return an "Out
of memory" error. I discovered that there was no check for a
zero/negative value for dev_size_mb and thus a vmalloc(0) resulted,
which apparently results in a NULL pointer and the driver thinks there
is no memory available.

I believe the patch below fixes this.


Applys-to: 2.6.7

Description: Adds check for non-positive value of
scsi_debug_dev_size_mb, as per the description on the scsi_debug web
page. If the parameter is given as 0 or less, then the size of the
reserved RAM is defaulted to 1MB. Compile-tested and run-tested.

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>

--- linux-vanilla/drivers/scsi/scsi_debug.c	2004-06-15 22:19:37.000000000 -0700
+++ linux-dev/drivers/scsi/scsi_debug.c	2004-08-05 14:16:47.000000000 -0700
@@ -1491,6 +1491,10 @@ static int __init scsi_debug_init(void)
 	int host_to_add;
 	int k;
 
+	/* if dev_size_mb is passed as <= 0, then it is forced to 1. */
+	if (scsi_debug_dev_size_mb <= 0)
+		scsi_debug_dev_size_mb = 1;
+
 	sdebug_store_size = (unsigned long)scsi_debug_dev_size_mb * 1048576;
 	sdebug_capacity = sdebug_store_size / SECT_SIZE;
 

                 reply	other threads:[~2004-08-05 21:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20040805213547.GA3856@us.ibm.com \
    --to=nacc@us.ibm.com \
    --cc=James.Bottomley@SteelEye.com \
    --cc=dgilbert@interlog.com \
    --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.