From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753355Ab3AKNwJ (ORCPT ); Fri, 11 Jan 2013 08:52:09 -0500 Received: from mail-bk0-f47.google.com ([209.85.214.47]:38099 "EHLO mail-bk0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751113Ab3AKNwI (ORCPT ); Fri, 11 Jan 2013 08:52:08 -0500 From: Alexandru Copot To: rusty@rustcorp.com.au Cc: mst@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, Alexandru Copot , Daniel Baluta Subject: [PATCH] virtio: suppress kmemleak false positive Date: Fri, 11 Jan 2013 15:51:43 +0200 Message-Id: <1357912303-17026-1-git-send-email-alex.mihai.c@gmail.com> X-Mailer: git-send-email 1.8.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While doing simple IPv6 tests in KVM virtual machines, (add an IPv6 address to eth0) kmemleak complains about an unreferenced object: unreferenced object 0xffff88001e804120 (size 32): comm "softirq", pid 0, jiffies 4294900928 (age 631.544s) hex dump (first 32 bytes): 28 cb fd 1d 00 00 00 00 0c 00 00 00 01 00 01 00 (............... 02 d0 83 1d 00 00 00 00 6e 00 00 00 00 00 00 00 ........n....... backtrace: [] kmemleak_alloc+0x21/0x50 [] __kmalloc+0xe0/0x160 [] virtqueue_add_buf+0x1fc/0x3d0 [] start_xmit+0x153/0x3a0 [] dev_hard_start_xmit+0x21e/0x470 [] sch_direct_xmit+0xfe/0x280 [] dev_queue_xmit+0x1f4/0x5d0 [] ip6_finish_output2+0x101/0x450 [] ip6_finish_output+0x98/0x200 [] ip6_output+0x51/0x1b0 [] mld_sendpack+0x19f/0x360 [] mld_ifc_timer_expire+0x194/0x290 [] call_timer_fn+0x74/0xf0 [] run_timer_softirq+0x18b/0x220 [] __do_softirq+0xe1/0x1c0 [] call_softirq+0x1c/0x30 Seems the function vring_add_indirect stores an array of struct vring_desc by using virt_to_phys and kmemleak doesn't track the pointer. The following patch can fix this. Signed-off-by: Alexandru Copot CC: Daniel Baluta --- drivers/virtio/virtio_ring.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index ffd7e7d..e0b591b 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -23,6 +23,7 @@ #include #include #include +#include /* virtio guest is communicating with a virtual "device" that actually runs on * a host processor. Memory barriers are used to control SMP effects. */ @@ -140,6 +141,7 @@ static int vring_add_indirect(struct vring_virtqueue *vq, desc = kmalloc((out + in) * sizeof(struct vring_desc), gfp); if (!desc) return -ENOMEM; + kmemleak_not_leak(desc); /* Transfer entries from the sg list into the indirect page */ for (i = 0; i < out; i++) { -- 1.8.1