Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1598933 > unrolled thread
| Started by | Gerd Hoffmann <kraxel@redhat.com> |
|---|---|
| First post | 2017-03-13 09:30 +0100 |
| Last post | 2017-03-13 11:30 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] drm: virtio: fix kmem_cache_alloc error check Gerd Hoffmann <kraxel@redhat.com> - 2017-03-13 09:30 +0100
Re: [PATCH] drm: virtio: fix kmem_cache_alloc error check Daniel Vetter <daniel@ffwll.ch> - 2017-03-13 11:30 +0100
| From | Gerd Hoffmann <kraxel@redhat.com> |
|---|---|
| Date | 2017-03-13 09:30 +0100 |
| Subject | [PATCH] drm: virtio: fix kmem_cache_alloc error check |
| Message-ID | <tktwB-6ak-3@gated-at.bofh.it> |
kmem_cache_alloc returns NULL on error, not ERR_PTR. Fixes: f5985bf9cadd4e3ed8d5d9a9cbbb2e39cdb81cd9 Reported-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- drivers/gpu/drm/virtio/virtgpu_vq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index 472e349..9eb96fb2 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -97,8 +97,8 @@ void virtio_gpu_free_vbufs(struct virtio_gpu_device *vgdev) struct virtio_gpu_vbuffer *vbuf; vbuf = kmem_cache_alloc(vgdev->vbufs, GFP_KERNEL); - if (IS_ERR(vbuf)) - return ERR_CAST(vbuf); + if (!vbuf) + return ERR_PTR(-ENOMEM); memset(vbuf, 0, VBUFFER_SIZE); BUG_ON(size > MAX_INLINE_CMD_SIZE); -- 1.8.3.1
[toc] | [next] | [standalone]
| From | Daniel Vetter <daniel@ffwll.ch> |
|---|---|
| Date | 2017-03-13 11:30 +0100 |
| Message-ID | <tkvoJ-7zi-7@gated-at.bofh.it> |
| In reply to | #1598933 |
On Mon, Mar 13, 2017 at 09:22:26AM +0100, Gerd Hoffmann wrote: > kmem_cache_alloc returns NULL on error, not ERR_PTR. > > Fixes: f5985bf9cadd4e3ed8d5d9a9cbbb2e39cdb81cd9 > Reported-by: Jiri Slaby <jslaby@suse.cz> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> I guess we should have smatch integrated into 0day to catch these ... Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> > --- > drivers/gpu/drm/virtio/virtgpu_vq.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c > index 472e349..9eb96fb2 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_vq.c > +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c > @@ -97,8 +97,8 @@ void virtio_gpu_free_vbufs(struct virtio_gpu_device *vgdev) > struct virtio_gpu_vbuffer *vbuf; > > vbuf = kmem_cache_alloc(vgdev->vbufs, GFP_KERNEL); > - if (IS_ERR(vbuf)) > - return ERR_CAST(vbuf); > + if (!vbuf) > + return ERR_PTR(-ENOMEM); > memset(vbuf, 0, VBUFFER_SIZE); > > BUG_ON(size > MAX_INLINE_CMD_SIZE); > -- > 1.8.3.1 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web