All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	David Vrabel <david.vrabel@citrix.com>,
	Juergen Gross <jgross@suse.com>
Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org,
	Heinrich Schuchardt <xypron.glpk@gmx.de>
Subject: [PATCH 1/1] xen/gntdev: kmalloc structure gntdev_copy_batch
Date: Sat,  7 May 2016 10:17:26 +0200	[thread overview]
Message-ID: <1462609046-10559-1-git-send-email-xypron.glpk@gmx.de> (raw)

Commit a4cdb556cae0 ("xen/gntdev: add ioctl for grant copy")
leads to a warning
xen/gntdev.c: In function ‘gntdev_ioctl_grant_copy’:
xen/gntdev.c:949:1: warning: the frame size of 1248 bytes
is larger than 1024 bytes [-Wframe-larger-than=]

This can be avoided by using kmalloc instead of the stack.

Testing requires CONFIG_XEN_GNTDEV.

Fixes: a4cdb556cae0 ("xen/gntdev: add ioctl for grant copy")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 drivers/xen/gntdev.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index dc49538..e8aec48 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -915,36 +915,43 @@ static int gntdev_grant_copy_seg(struct gntdev_copy_batch *batch,
 static long gntdev_ioctl_grant_copy(struct gntdev_priv *priv, void __user *u)
 {
 	struct ioctl_gntdev_grant_copy copy;
-	struct gntdev_copy_batch batch;
+	struct gntdev_copy_batch *batch;
 	unsigned int i;
 	int ret = 0;
 
+	batch = kmalloc(sizeof(struct gntdev_copy_batch), GFP_KERNEL);
+	if (!batch)
+		return -ENOMEM;
+
 	if (copy_from_user(&copy, u, sizeof(copy)))
 		return -EFAULT;
 
-	batch.nr_ops = 0;
-	batch.nr_pages = 0;
+	batch->nr_ops = 0;
+	batch->nr_pages = 0;
 
 	for (i = 0; i < copy.count; i++) {
 		struct gntdev_grant_copy_segment seg;
 
 		if (copy_from_user(&seg, &copy.segments[i], sizeof(seg))) {
 			ret = -EFAULT;
-			goto out;
+			goto failed;
 		}
 
-		ret = gntdev_grant_copy_seg(&batch, &seg, &copy.segments[i].status);
+		ret = gntdev_grant_copy_seg(batch, &seg,
+					    &copy.segments[i].status);
 		if (ret < 0)
-			goto out;
+			goto failed;
 
 		cond_resched();
 	}
-	if (batch.nr_ops)
-		ret = gntdev_copy(&batch);
-	return ret;
+	if (batch->nr_ops)
+		ret = gntdev_copy(batch);
+	goto out;
 
-  out:
-	gntdev_put_pages(&batch);
+failed:
+	gntdev_put_pages(batch);
+out:
+	kfree(batch);
 	return ret;
 }
 
-- 
2.1.4

             reply	other threads:[~2016-05-07  8:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-07  8:17 Heinrich Schuchardt [this message]
2016-05-09  5:25 ` [PATCH 1/1] xen/gntdev: kmalloc structure gntdev_copy_batch Juergen Gross
2016-05-09  5:25 ` Juergen Gross
2016-05-09  6:06 ` Jan Beulich
2016-05-09  6:06 ` [Xen-devel] " Jan Beulich
2016-05-09 10:30 ` David Vrabel
2016-05-09 10:30 ` David Vrabel
  -- strict thread matches above, loose matches on Subject: below --
2016-05-07  8:17 Heinrich Schuchardt

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=1462609046-10559-1-git-send-email-xypron.glpk@gmx.de \
    --to=xypron.glpk@gmx.de \
    --cc=boris.ostrovsky@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xen-devel@lists.xenproject.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.