提交 668866b6 编写于 作者: M Markus Elfring 提交者: Michael S. Tsirkin

virtio_blk: Use kmalloc_array() in init_vq()

Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.
Signed-off-by: NMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
上级 3dae2c61
...@@ -390,13 +390,13 @@ static int init_vq(struct virtio_blk *vblk) ...@@ -390,13 +390,13 @@ static int init_vq(struct virtio_blk *vblk)
if (err) if (err)
num_vqs = 1; num_vqs = 1;
vblk->vqs = kmalloc(sizeof(*vblk->vqs) * num_vqs, GFP_KERNEL); vblk->vqs = kmalloc_array(num_vqs, sizeof(*vblk->vqs), GFP_KERNEL);
if (!vblk->vqs) if (!vblk->vqs)
return -ENOMEM; return -ENOMEM;
names = kmalloc(sizeof(*names) * num_vqs, GFP_KERNEL); names = kmalloc_array(num_vqs, sizeof(*names), GFP_KERNEL);
callbacks = kmalloc(sizeof(*callbacks) * num_vqs, GFP_KERNEL); callbacks = kmalloc_array(num_vqs, sizeof(*callbacks), GFP_KERNEL);
vqs = kmalloc(sizeof(*vqs) * num_vqs, GFP_KERNEL); vqs = kmalloc_array(num_vqs, sizeof(*vqs), GFP_KERNEL);
if (!names || !callbacks || !vqs) { if (!names || !callbacks || !vqs) {
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册