mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tim Gardner <tim.gardner@canonical.com>
To: linux-kernel@vger.kernel.org
Cc: Tim Gardner <tim.gardner@canonical.com>,
	Chirag Kantharia <chirag.kantharia@hp.com>,
	iss_storagedev@hp.com
Subject: [PATCH linux-next] cpqarray: do_ida_request() - reduce stack frame size
Date: Mon, 18 Feb 2013 13:35:58 -0700	[thread overview]
Message-ID: <1361219758-112250-1-git-send-email-tim.gardner@canonical.com> (raw)

do_ida_request() can be called from within interrupt context.
A stack frame of more then 1K runs the risk of overflowing the
kernel stack. Correct this situation by dynamically allocating
the large (and temporary) scatter/gather array. A failure from kmalloc()
will leave a stack trace in the kernel log.

drivers/block/cpqarray.c: In function ‘do_ida_request’:
drivers/block/cpqarray.c:969:1: warning: the frame size of 1072 bytes is larger than 1024 bytes [-Wframe-larger-than=]

Cc: Chirag Kantharia <chirag.kantharia@hp.com>
Cc: iss_storagedev@hp.com
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 drivers/block/cpqarray.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 3f08713..2715b35 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -908,9 +908,13 @@ static void do_ida_request(struct request_queue *q)
 	ctlr_info_t *h = q->queuedata;
 	cmdlist_t *c;
 	struct request *creq;
-	struct scatterlist tmp_sg[SG_MAX];
+	struct scatterlist *tmp_sg;
 	int i, dir, seg;
 
+	tmp_sg = kmalloc(sizeof(*tmp_sg) * SG_MAX, GFP_ATOMIC);
+	if (!tmp_sg)
+		return;
+
 queue_next:
 	creq = blk_peek_request(q);
 	if (!creq)
@@ -966,6 +970,7 @@ DBGPX(	printk("Submitting %u sectors in %d segments\n", blk_rq_sectors(creq), se
 
 startio:
 	start_io(h);
+	kfree(tmp_sg);
 }
 
 /* 
-- 
1.7.9.5


                 reply	other threads:[~2013-02-18 20:36 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=1361219758-112250-1-git-send-email-tim.gardner@canonical.com \
    --to=tim.gardner@canonical.com \
    --cc=chirag.kantharia@hp.com \
    --cc=iss_storagedev@hp.com \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®