dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: lustre: llite: kzalloc/copy_to_user to memdup_user
@ 2016-05-22 21:49 Tobin C Harding
       [not found] ` <1463953771-16942-1-git-send-email-me-xzjC0nNlxno@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Tobin C Harding @ 2016-05-22 21:49 UTC (permalink / raw)
  To: patrik.r.jakobsson
  Cc: Dmitry Eremin, Abdul Hussain, David Airlie, Greg Kroah-Hartman,
	James Nunez,
	open list:DRM DRIVERS FOR GMA500 Poulsbo, Moorestown and..., linux-kernel@vger.kernel.org open list, lustre-devel@lists.lustre.org moderated list:STAGING - LUSTRE PARALLEL FILESYSTEM, devel@driverdev.osuosl.org open list:STAGING SUBSYSTEM,
	Oleg Drokin, Julia Lawall, Al Viro, Andreas Dilger,
	John L. Hammond, Frank Zago, Kirill A. Shutemov, Tobin C Harding

kzalloc call followed by copy_to_user can be replaced by call to memdup_user.

Signed-off-by: Tobin C Harding <me@tobin.cc>
---
 drivers/gpu/drm/gma500/gma_display.c      |  2 +-
 drivers/staging/lustre/lustre/llite/dir.c | 22 +++++++---------------
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
index 5bf765d..8a1fb25 100644
--- a/drivers/gpu/drm/gma500/gma_display.c
+++ b/drivers/gpu/drm/gma500/gma_display.c
@@ -285,7 +285,7 @@ void gma_crtc_dpms(struct drm_crtc *crtc, int mode)
 
 		/* Wait for vblank for the disable to take effect */
 		gma_wait_for_vblank(dev);
-
+l
 		/* Disable plane */
 		temp = REG_READ(map->cntr);
 		if ((temp & DISPLAY_PLANE_ENABLE) != 0) {
diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c
index 4b00d1a..b0eb102 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -1076,19 +1076,14 @@ static int copy_and_ioctl(int cmd, struct obd_export *exp,
 	void *copy;
 	int rc;
 
-	copy = kzalloc(size, GFP_NOFS);
-	if (!copy)
-		return -ENOMEM;
-
-	if (copy_from_user(copy, data, size)) {
-		rc = -EFAULT;
+	copy = memdup_user(data, size);
+	if (IS_ERR(copy)) {
+		rc = PTR_ERR(copy);
 		goto out;
 	}
 
 	rc = obd_iocontrol(cmd, exp, size, copy, NULL);
 out:
-	kfree(copy);
-
 	return rc;
 }
 
@@ -1689,12 +1684,9 @@ out_poll:
 	case LL_IOC_QUOTACTL: {
 		struct if_quotactl *qctl;
 
-		qctl = kzalloc(sizeof(*qctl), GFP_NOFS);
-		if (!qctl)
-			return -ENOMEM;
-
-		if (copy_from_user(qctl, (void __user *)arg, sizeof(*qctl))) {
-			rc = -EFAULT;
+		qctl = memdup_user((void __user *)arg, sizeof(*qctl));
+		if (IS_ERR(qctl)) {
+			rc = PTR_ERR(qctl);
 			goto out_quotactl;
 		}
 
@@ -1704,8 +1696,8 @@ out_poll:
 					    sizeof(*qctl)))
 			rc = -EFAULT;
 
-out_quotactl:
 		kfree(qctl);
+out_quotactl:
 		return rc;
 	}
 	case OBD_IOC_GETDTNAME:
-- 
2.8.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] staging: lustre: llite: kzalloc/copy_to_user to memdup_user
@ 2016-05-22 21:52 Tobin C Harding
  0 siblings, 0 replies; 4+ messages in thread
From: Tobin C Harding @ 2016-05-22 21:52 UTC (permalink / raw)
  To: patrik.r.jakobsson
  Cc: Dmitry Eremin, Abdul Hussain, David Airlie, Greg Kroah-Hartman,
	James Nunez,
	open list:DRM DRIVERS FOR GMA500 Poulsbo, Moorestown and..., linux-kernel@vger.kernel.org open list, lustre-devel@lists.lustre.org moderated list:STAGING - LUSTRE PARALLEL FILESYSTEM, devel@driverdev.osuosl.org open list:STAGING SUBSYSTEM,
	Oleg Drokin, Julia Lawall, Al Viro, Andreas Dilger,
	John L. Hammond, Frank Zago, Kirill A. Shutemov, Tobin C Harding

kzalloc call followed by copy_to_user can be replaced by call to memdup_user.

Signed-off-by: Tobin C Harding <me@tobin.cc>
---
 drivers/gpu/drm/gma500/gma_display.c      |  2 +-
 drivers/staging/lustre/lustre/llite/dir.c | 22 +++++++---------------
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
index 5bf765d..8a1fb25 100644
--- a/drivers/gpu/drm/gma500/gma_display.c
+++ b/drivers/gpu/drm/gma500/gma_display.c
@@ -285,7 +285,7 @@ void gma_crtc_dpms(struct drm_crtc *crtc, int mode)
 
 		/* Wait for vblank for the disable to take effect */
 		gma_wait_for_vblank(dev);
-
+l
 		/* Disable plane */
 		temp = REG_READ(map->cntr);
 		if ((temp & DISPLAY_PLANE_ENABLE) != 0) {
diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c
index 4b00d1a..b0eb102 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -1076,19 +1076,14 @@ static int copy_and_ioctl(int cmd, struct obd_export *exp,
 	void *copy;
 	int rc;
 
-	copy = kzalloc(size, GFP_NOFS);
-	if (!copy)
-		return -ENOMEM;
-
-	if (copy_from_user(copy, data, size)) {
-		rc = -EFAULT;
+	copy = memdup_user(data, size);
+	if (IS_ERR(copy)) {
+		rc = PTR_ERR(copy);
 		goto out;
 	}
 
 	rc = obd_iocontrol(cmd, exp, size, copy, NULL);
 out:
-	kfree(copy);
-
 	return rc;
 }
 
@@ -1689,12 +1684,9 @@ out_poll:
 	case LL_IOC_QUOTACTL: {
 		struct if_quotactl *qctl;
 
-		qctl = kzalloc(sizeof(*qctl), GFP_NOFS);
-		if (!qctl)
-			return -ENOMEM;
-
-		if (copy_from_user(qctl, (void __user *)arg, sizeof(*qctl))) {
-			rc = -EFAULT;
+		qctl = memdup_user((void __user *)arg, sizeof(*qctl));
+		if (IS_ERR(qctl)) {
+			rc = PTR_ERR(qctl);
 			goto out_quotactl;
 		}
 
@@ -1704,8 +1696,8 @@ out_poll:
 					    sizeof(*qctl)))
 			rc = -EFAULT;
 
-out_quotactl:
 		kfree(qctl);
+out_quotactl:
 		return rc;
 	}
 	case OBD_IOC_GETDTNAME:
-- 
2.8.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: lustre: llite: kzalloc/copy_to_user to memdup_user
       [not found] ` <1463953771-16942-1-git-send-email-me-xzjC0nNlxno@public.gmane.org>
@ 2016-05-22 22:25   ` Greg Kroah-Hartman
  2016-05-23  0:20     ` Tobin Harding
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2016-05-22 22:25 UTC (permalink / raw)
  To: Tobin C Harding
  Cc: devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b, Abdul Hussain,
	David Airlie, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	patrik.r.jakobsson-Re5JQEeQqe8AvxtiuMwx3w,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Oleg Drokin, Julia Lawall,
	Al Viro, Frank Zago, Kirill A. Shutemov,
	lustre-devel-aLEFhgZF4x6X6Mz3xDxJMA

On Mon, May 23, 2016 at 07:49:29AM +1000, Tobin C Harding wrote:
> kzalloc call followed by copy_to_user can be replaced by call to memdup_user.
> 
> Signed-off-by: Tobin C Harding <me-xzjC0nNlxno@public.gmane.org>

Why did you send this twice?

> ---
>  drivers/gpu/drm/gma500/gma_display.c      |  2 +-
>  drivers/staging/lustre/lustre/llite/dir.c | 22 +++++++---------------
>  2 files changed, 8 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
> index 5bf765d..8a1fb25 100644
> --- a/drivers/gpu/drm/gma500/gma_display.c
> +++ b/drivers/gpu/drm/gma500/gma_display.c
> @@ -285,7 +285,7 @@ void gma_crtc_dpms(struct drm_crtc *crtc, int mode)
>  
>  		/* Wait for vblank for the disable to take effect */
>  		gma_wait_for_vblank(dev);
> -
> +l

What?  What does this have to do with lustre?

It's kind of obvious you didn't build this :(

Please be more careful in the future.

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: lustre: llite: kzalloc/copy_to_user to memdup_user
  2016-05-22 22:25   ` Greg Kroah-Hartman
@ 2016-05-23  0:20     ` Tobin Harding
  0 siblings, 0 replies; 4+ messages in thread
From: Tobin Harding @ 2016-05-23  0:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: devel, Dmitry Eremin, Abdul Hussain, Andreas Dilger, David Airlie,
	dri-devel, James Nunez, patrik.r.jakobsson, linux-kernel,
	Oleg Drokin, Julia Lawall, Al Viro, John L. Hammond, Frank Zago,
	Kirill A. Shutemov, lustre-devel

On Sun, May 22, 2016 at 03:25:38PM -0700, Greg Kroah-Hartman wrote:
> On Mon, May 23, 2016 at 07:49:29AM +1000, Tobin C Harding wrote:
> > kzalloc call followed by copy_to_user can be replaced by call to memdup_user.
> > 
> > Signed-off-by: Tobin C Harding <me@tobin.cc>
>
> Why did you send this twice?

Because I'm a git send-email amateur.

> > ---
> >  drivers/gpu/drm/gma500/gma_display.c      |  2 +-
> >  drivers/staging/lustre/lustre/llite/dir.c | 22 +++++++---------------
> >  2 files changed, 8 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
> > index 5bf765d..8a1fb25 100644
> > --- a/drivers/gpu/drm/gma500/gma_display.c
> > +++ b/drivers/gpu/drm/gma500/gma_display.c
> > @@ -285,7 +285,7 @@ void gma_crtc_dpms(struct drm_crtc *crtc, int mode)
> >  
> >             /* Wait for vblank for the disable to take effect */
> >             gma_wait_for_vblank(dev);
> > -
> > +l
>
> What?  What does this have to do with lustre?

Turns out I'm a git amateur in general, the gma_display changes should not have
been committed on this branch.

> It's kind of obvious you didn't build this :(

Epic fail.

> Please be more careful in the future.
>
> greg k-h

I am humbly attempting to learn the way of kernel dev, thank you for your
patience, I will endeavor to be more careful.

Regards,
Tobin Harding.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-05-23  0:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-22 21:52 [PATCH] staging: lustre: llite: kzalloc/copy_to_user to memdup_user Tobin C Harding
  -- strict thread matches above, loose matches on Subject: below --
2016-05-22 21:49 Tobin C Harding
     [not found] ` <1463953771-16942-1-git-send-email-me-xzjC0nNlxno@public.gmane.org>
2016-05-22 22:25   ` Greg Kroah-Hartman
2016-05-23  0:20     ` Tobin Harding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).