Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1396604
| From | "Jan Beulich" <jbeulich@suse.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [Xen-devel] [PATCH 1/1] xen/gntdev: kmalloc structure gntdev_copy_batch |
| Date | 2016-05-09 08:10 +0200 |
| Message-ID | <rwMye-6PA-9@gated-at.bofh.it> (permalink) |
| References | <rw5CV-6kg-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
>>> Heinrich Schuchardt <xypron.glpk@gmx.de> 05/08/16 8:13 AM >>>
>--- 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(©, u, sizeof(copy)))
>return -EFAULT;
You carefully fix up all other error return paths below, but not the one above,
resulting in a memory leak.
>- out:
>- gntdev_put_pages(&batch);
>+failed:
>+ gntdev_put_pages(batch);
>+out:
>+ kfree(batch);
I'm not sure what the conventions are for label placement in the kernel sources,
but "out" having been indented by one space (which you ditch) avoided diff's -p
option picking up the label instead of the function head as context.
Jan
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 1/1] xen/gntdev: kmalloc structure gntdev_copy_batch Heinrich Schuchardt <xypron.glpk@gmx.de> - 2016-05-07 10:20 +0200 Re: [PATCH 1/1] xen/gntdev: kmalloc structure gntdev_copy_batch Juergen Gross <jgross@suse.com> - 2016-05-09 07:30 +0200 Re: [Xen-devel] [PATCH 1/1] xen/gntdev: kmalloc structure gntdev_copy_batch "Jan Beulich" <jbeulich@suse.com> - 2016-05-09 08:10 +0200 Re: [Xen-devel] [PATCH 1/1] xen/gntdev: kmalloc structure gntdev_copy_batch David Vrabel <david.vrabel@citrix.com> - 2016-05-09 12:40 +0200
csiph-web