From: kbuild test robot <lkp(a)intel.com>
drivers/media/virtio/virtio_video_vq.c:92:8-24: WARNING: kmem_cache_zalloc should be used
for vbuf, instead of kmem_cache_alloc/memset
Use zeroing allocator rather than allocator followed by memset with 0
This considers some simple cases that are common and easy to validate
Note in particular that there are no ...s in the rule, so all of the
matched code has to be contiguous
Generated by: scripts/coccinelle/api/alloc/zalloc-simple.cocci
Fixes: bbca48582a73 ("BACKPORT: FROMLIST: virtio_video: Add the Virtio Video V4L2
driver")
CC: Dmitry Sepp <dmitry.sepp(a)opensynergy.com>
Signed-off-by: kbuild test robot <lkp(a)intel.com>
---
tree:
https://chromium.googlesource.com/chromiumos/third_party/kernel chromeos-5.4
head: 4ab03425ee573fd6b97746d319f2c88b465a1534
commit: bbca48582a7342c1201691ce0eb08f1538376538 [34/43] BACKPORT: FROMLIST: virtio_video:
Add the Virtio Video V4L2 driver
Please take the patch only if it's a positive warning. Thanks!
virtio_video_vq.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
--- a/drivers/media/virtio/virtio_video_vq.c
+++ b/drivers/media/virtio/virtio_video_vq.c
@@ -89,10 +89,9 @@ virtio_video_get_vbuf(struct virtio_vide
{
struct virtio_video_vbuffer *vbuf;
- vbuf = kmem_cache_alloc(vv->vbufs, GFP_KERNEL);
+ vbuf = kmem_cache_zalloc(vv->vbufs, GFP_KERNEL);
if (!vbuf)
return ERR_PTR(-ENOMEM);
- memset(vbuf, 0, VBUFFER_SIZE);
BUG_ON(size > MAX_INLINE_CMD_SIZE);
vbuf->buf = (void *)vbuf + sizeof(*vbuf);