Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1646231 > unrolled thread

[PATCH -next] drm/vgem: Fix return value check in vgem_init()

Started byWei Yongjun <weiyj.lk@gmail.com>
First post2017-05-21 03:30 +0200
Last post2017-05-22 09:50 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH -next] drm/vgem: Fix return value check in vgem_init() Wei Yongjun <weiyj.lk@gmail.com> - 2017-05-21 03:30 +0200
    Re: [PATCH -next] drm/vgem: Fix return value check in vgem_init() Chris Wilson <chris@chris-wilson.co.uk> - 2017-05-21 14:10 +0200
      Re: [PATCH -next] drm/vgem: Fix return value check in vgem_init() Daniel Vetter <daniel@ffwll.ch> - 2017-05-22 09:50 +0200

#1646231 — [PATCH -next] drm/vgem: Fix return value check in vgem_init()

FromWei Yongjun <weiyj.lk@gmail.com>
Date2017-05-21 03:30 +0200
Subject[PATCH -next] drm/vgem: Fix return value check in vgem_init()
Message-ID<tJnQZ-OO-1@gated-at.bofh.it>
From: Wei Yongjun <weiyongjun1@huawei.com>

In case of error, the function platform_device_register_simple() returns
ERR_PTR() and never returns NULL. The NULL test in the return value
check should be replaced with IS_ERR().

Fixes: 315f0242aa2b ("drm/vgem: Convert to a struct drm_device subclass")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/gpu/drm/vgem/vgem_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c
index 54ec94c..18f401b 100644
--- a/drivers/gpu/drm/vgem/vgem_drv.c
+++ b/drivers/gpu/drm/vgem/vgem_drv.c
@@ -438,8 +438,8 @@ static int __init vgem_init(void)
 
 	vgem_device->platform =
 		platform_device_register_simple("vgem", -1, NULL, 0);
-	if (!vgem_device->platform) {
-		ret = -ENODEV;
+	if (IS_ERR(vgem_device->platform)) {
+		ret = PTR_ERR(vgem_device->platform);
 		goto out_fini;
 	}

[toc] | [next] | [standalone]


#1646334

FromChris Wilson <chris@chris-wilson.co.uk>
Date2017-05-21 14:10 +0200
Message-ID<tJxQm-7Cj-13@gated-at.bofh.it>
In reply to#1646231
On Sun, May 21, 2017 at 01:19:39AM +0000, Wei Yongjun wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> In case of error, the function platform_device_register_simple() returns
> ERR_PTR() and never returns NULL. The NULL test in the return value
> check should be replaced with IS_ERR().
> 
> Fixes: 315f0242aa2b ("drm/vgem: Convert to a struct drm_device subclass")

This is wrong, the bug was introduced in
af33a9190d02 ("drm/vgem: Enable dmabuf import interfaces")
not that it matters since it is the same tag.

> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Checked it is an ERR_PTR return on failure, so
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

[toc] | [prev] | [next] | [standalone]


#1646579

FromDaniel Vetter <daniel@ffwll.ch>
Date2017-05-22 09:50 +0200
Message-ID<tJQgi-2Cc-15@gated-at.bofh.it>
In reply to#1646334
On Sun, May 21, 2017 at 01:09:05PM +0100, Chris Wilson wrote:
> On Sun, May 21, 2017 at 01:19:39AM +0000, Wei Yongjun wrote:
> > From: Wei Yongjun <weiyongjun1@huawei.com>
> > 
> > In case of error, the function platform_device_register_simple() returns
> > ERR_PTR() and never returns NULL. The NULL test in the return value
> > check should be replaced with IS_ERR().
> > 
> > Fixes: 315f0242aa2b ("drm/vgem: Convert to a struct drm_device subclass")
> 
> This is wrong, the bug was introduced in
> af33a9190d02 ("drm/vgem: Enable dmabuf import interfaces")
> not that it matters since it is the same tag.

Fixed.

> > Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> 
> Checked it is an ERR_PTR return on failure, so
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Applied, thanks for patch&review.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web