lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9a241e38-c263-f50d-120c-17fdda9d2499@suse.cz>
Date:   Fri, 10 Mar 2017 19:12:24 +0100
From:   Jiri Slaby <jslaby@...e.cz>
To:     Gerd Hoffmann <kraxel@...hat.com>, dri-devel@...ts.freedesktop.org
Cc:     David Airlie <airlied@...ux.ie>,
        "open list:VIRTIO GPU DRIVER" 
        <virtualization@...ts.linux-foundation.org>,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] drm: virtio: use kmem_cache

On 03/01/2017, 03:09 PM, Gerd Hoffmann wrote:
> @@ -128,12 +96,9 @@ void virtio_gpu_free_vbufs(struct virtio_gpu_device *vgdev)
>  {
>  	struct virtio_gpu_vbuffer *vbuf;
>  
> -	spin_lock(&vgdev->free_vbufs_lock);
> -	BUG_ON(list_empty(&vgdev->free_vbufs));
> -	vbuf = list_first_entry(&vgdev->free_vbufs,
> -				struct virtio_gpu_vbuffer, list);
> -	list_del(&vbuf->list);
> -	spin_unlock(&vgdev->free_vbufs_lock);
> +	vbuf = kmem_cache_alloc(vgdev->vbufs, GFP_KERNEL);
> +	if (IS_ERR(vbuf))
> +		return ERR_CAST(vbuf);

AFAICS kmem_cache_alloc returns NULL on error.

>  	memset(vbuf, 0, VBUFFER_SIZE);
>  
>  	BUG_ON(size > MAX_INLINE_CMD_SIZE);
> @@ -208,9 +173,7 @@ static void free_vbuf(struct virtio_gpu_device *vgdev,
>  	if (vbuf->resp_size > MAX_INLINE_RESP_SIZE)
>  		kfree(vbuf->resp_buf);
>  	kfree(vbuf->data_buf);
> -	spin_lock(&vgdev->free_vbufs_lock);
> -	list_add(&vbuf->list, &vgdev->free_vbufs);
> -	spin_unlock(&vgdev->free_vbufs_lock);
> +	kmem_cache_free(vgdev->vbufs, vbuf);
>  }
>  
>  static void reclaim_vbufs(struct virtqueue *vq, struct list_head *reclaim_list)
> 

regards,
-- 
js
suse labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ