]> asedeno.scripts.mit.edu Git - linux.git/commit
PCI: hv: Avoid a kmemleak false positive caused by the hbus buffer
authorDexuan Cui <decui@microsoft.com>
Mon, 25 Nov 2019 05:33:54 +0000 (21:33 -0800)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tue, 26 Nov 2019 10:34:03 +0000 (10:34 +0000)
commit877b911a5ba0733f62239055ee869f2e117b57da
tree1493d60ec85c594d1b39bda233cd28c9ec42f523
parent14ef39fddd2367523de25b87dccfe6422c3f3efa
PCI: hv: Avoid a kmemleak false positive caused by the hbus buffer

With the recent 59bb47985c1d ("mm, sl[aou]b: guarantee natural
alignment for kmalloc(power-of-two)"), kzalloc() is able to allocate
a 4KB buffer that is guaranteed to be 4KB-aligned. Here the size and
alignment of hbus is important because hbus's field
retarget_msi_interrupt_params must not cross a 4KB page boundary.

Here we prefer kzalloc to get_zeroed_page(), because a buffer
allocated by the latter is not tracked and scanned by kmemleak, and
hence kmemleak reports the pointer contained in the hbus buffer
(i.e. the hpdev struct, which is created in new_pcichild_device() and
is tracked by hbus->children) as memory leak (false positive).

If the kernel doesn't have 59bb47985c1d, get_zeroed_page() *must* be
used to allocate the hbus buffer and we can avoid the kmemleak false
positive by using kmemleak_alloc() and kmemleak_free() to ask
kmemleak to track and scan the hbus buffer.

Reported-by: Lili Deng <v-lide@microsoft.com>
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
drivers/pci/controller/pci-hyperv.c