Skip to contentSkip to conversation

pci: Use kzalloc() in pci_create_bus()

PATCH Applied Geert Uytterhoeven 2 participants 2 messages Mar 15, 2009 – Mar 20, 2009 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci: Use kzalloc() in pci_create_bus()

---
1. Untested ;-)
2. Probably none of the static analyzers noticed, because of the amount of code in between the kmalloc() and the memset()

drivers/pci/probe.c +1 -2
index 55ec44a..fa0999f 100644
@@ -1114,7 +1114,7 @@ struct pci_bus * pci_create_bus(struct device *parent,
 	if (!b)
 		return NULL;
 
-	dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev){
 		kfree(b);
 		return NULL;
@@ -1133,7 +1133,6 @@ struct pci_bus * pci_create_bus(struct device *parent,
 	list_add_tail(&b->node, &pci_root_buses);
 	up_write(&pci_bus_sem);
 
-	memset(dev, 0, sizeof(*dev));
 	dev->parent = parent;
 	dev->release = pci_release_bus_bridge_dev;
 	dev_set_name(dev, "pci%04x:%02x", pci_domain_nr(b), bus);

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds