>>> Heinrich Schuchardt <xypron.g...@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 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel