PCI: hv: Remove unnecessary type casting from kzalloc
Subsystems (4)
Dexuan Cui
maintainerPATCH v2 1/2 PCI: hv: Remove unnecessary type casting from kzalloc
In C, there is no need to cast a void * to any other pointer type.
Fixes 877b911a5ba0 ("PCI: hv: Avoid a kmemleak false positive caused by the hbus buffer")
Signed-off-by Dexuan Cui <[email protected]>
Reviewed-by Michael Kelley <[email protected]>
---
Change in v2: this was part of v1.
drivers/pci/controller/pci-hyperv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pci-hyperv.c +1 -1
@@ -2922,7 +2922,7 @@ static int hv_pci_probe(struct hv_device *hdev,* positive by using kmemleak_alloc() and kmemleak_free() to ask * kmemleak to track and scan the hbus buffer. */ - hbus = (struct hv_pcibus_device *)kzalloc (HV_HYP_PAGE_SIZE ,GFP_KERNEL ); + hbus =kzalloc (HV_HYP_PAGE_SIZE ,GFP_KERNEL );if (!hbus)return -ENOMEM ; hbus->state = hv_pcibus_init;
Signature · 1 line
2.19.1
Dexuan Cui
maintainerPATCH v2 2/2 PCI: hv: Use kfree(hbus) in hv_pci_probe()'s error handling path
Now that we use kzalloc() to allocate the hbus buffer, we should use kfree() in the error path as well.
Fixes 877b911a5ba0 ("PCI: hv: Avoid a kmemleak false positive caused by the hbus buffer")
Signed-off-by Dexuan Cui <[email protected]>
Reviewed-by Michael Kelley <[email protected]>
--- drivers/pci/controller/pci-hyperv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Change in v2: this was part of v1.
drivers/pci/controller/pci-hyperv.c +1 -1
@@ -3058,7 +3058,7 @@ static int hv_pci_probe(struct hv_device *hdev, free_dom:hv_put_dom_num (hbus->sysdata.domain); free_bus: -free_page ((unsigned long )hbus); +kfree (hbus);return ret; }
Signature · 1 line
2.19.1
Lorenzo Pieralisi
AppliedQuoted 3 lines · Dexuan Cui
In C, there is no need to cast a void * to any other pointer type.
Fixes 877b911a5ba0 ("PCI: hv: Avoid a kmemleak false positive caused by the hbus buffer")
This patch fixes nothing, anyway, that's a leftover that I removed.
Applied the series to pci/hv for v5.7.
Thanks,
Lorenzo
Quoted 25 lines
Signed-off-by Dexuan Cui <[email protected]>Reviewed-by Michael Kelley <[email protected]>---
Change in v2: this was part of v1.
drivers/pci/controller/pci-hyperv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/controller/pci-hyperv.c +1
-1@@ -2922,7 +2922,7 @@ static int hv_pci_probe(struct hv_device *hdev,* positive by using kmemleak_alloc() and kmemleak_free() to ask * kmemleak to track and scan the hbus buffer. */ - hbus = (struct hv_pcibus_device *)kzalloc (HV_HYP_PAGE_SIZE ,GFP_KERNEL ); + hbus =kzalloc (HV_HYP_PAGE_SIZE ,GFP_KERNEL );if (!hbus)return -ENOMEM ; hbus->state = hv_pcibus_init;Signature · 1 line
2.19.1