[PATCH] VMCI: fix kmemcheck warning.
From: Tetsuo Handa
Date: Sun Jul 24 2016 - 03:44:13 EST
kmemcheck complains that some of struct vmci_resource_query_msg members
allocated at vmci_check_host_caps() are not initialized before
vmci_send_datagram() is called. Add __GFP_ZERO to initialize explicitly.
[ 362.182231] vmw_vmci 0000:00:07.7: Found VMCI PCI device at 0x11080, irq 16
[ 362.188484] vmw_vmci 0000:00:07.7: Using capabilities 0xc
[ 362.191853] WARNING: kmemcheck: Caught 8-bit read from uninitialized memory (ffff88003adb799c)
[ 362.193582] 0000000000000000ffffffffffffffff0c00000000000000010000000088ffff
[ 362.196224] i i i i i i i i i i i i i i i i i i i i i i i i i i i i u u u u
[ 362.198800] ^
[ 362.200065] RIP: 0010:[<ffffffff812969f6>] [<ffffffff812969f6>] iowrite8_rep+0x36/0x50
[ 362.201685] RSP: 0018:ffff88003f5abca0 EFLAGS: 00010006
[ 362.202696] RAX: 000000000000000c RBX: 0000000000000282 RCX: 0000000000000008
[ 362.204111] RDX: 0000000000001090 RSI: ffff88003adb799c RDI: 0000000000001090
[ 362.205456] RBP: ffff88003f5abcb0 R08: 0000000000000067 R09: 0000000000000000
[ 362.206785] R10: ffff88003adb8980 R11: 0000000000000000 R12: ffff88003ee520a0
[ 362.208079] R13: ffff88003adb7980 R14: ffff88003ae0d798 R15: ffff88003ae0d7f0
[ 362.209520] FS: 0000000000000000(0000) GS:ffffffff8182c000(0000) knlGS:0000000000000000
[ 362.211143] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 362.212201] CR2: ffff88003f429240 CR3: 000000003ad71000 CR4: 00000000001406f0
[ 362.213552] [<ffffffff81394d72>] vmci_guest_probe_device+0x1e2/0x7b0
[ 362.214826] [<ffffffff812b2d64>] pci_device_probe+0x84/0xf0
[ 362.215952] [<ffffffff8137abd2>] driver_probe_device+0x182/0x2c0
[ 362.217118] [<ffffffff8137ad9e>] __driver_attach+0x8e/0xa0
[ 362.218246] [<ffffffff81378bfb>] bus_for_each_dev+0x6b/0xb0
[ 362.219387] [<ffffffff8137a5a9>] driver_attach+0x19/0x20
[ 362.220498] [<ffffffff8137a18b>] bus_add_driver+0x1ab/0x220
[ 362.221566] [<ffffffff8137b5db>] driver_register+0x5b/0xe0
[ 362.222695] [<ffffffff812b14aa>] __pci_register_driver+0x3a/0x40
[ 362.223885] [<ffffffff818cc767>] vmci_guest_init+0x19/0x1b
[ 362.224944] [<ffffffff818cc68f>] vmci_drv_init+0x35/0xd2
[ 362.226110] [<ffffffff8100041a>] do_one_initcall+0x4a/0x180
[ 362.227333] [<ffffffff818991d0>] kernel_init_freeable+0x15b/0x201
[ 362.228535] [<ffffffff815a6ff9>] kernel_init+0x9/0x100
[ 362.229547] [<ffffffff815b1c0f>] ret_from_fork+0x1f/0x40
[ 362.230580] [<ffffffffffffffff>] 0xffffffffffffffff
[ 362.231885] Guest personality initialized and is active
[ 362.233034] VMCI host device registered (name=vmci, major=10, minor=62)
[ 362.234278] Initialized host personality
Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
---
drivers/misc/vmw_vmci/vmci_guest.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/vmw_vmci/vmci_guest.c b/drivers/misc/vmw_vmci/vmci_guest.c
index 189b325..21707a9 100644
--- a/drivers/misc/vmw_vmci/vmci_guest.c
+++ b/drivers/misc/vmw_vmci/vmci_guest.c
@@ -172,7 +172,7 @@ static int vmci_check_host_caps(struct pci_dev *pdev)
VMCI_UTIL_NUM_RESOURCES * sizeof(u32);
struct vmci_datagram *check_msg;
- check_msg = kmalloc(msg_size, GFP_KERNEL);
+ check_msg = kmalloc(msg_size, GFP_KERNEL | __GFP_ZERO);
if (!check_msg) {
dev_err(&pdev->dev, "%s: Insufficient memory\n", __func__);
return -ENOMEM;
--
1.8.3.1