X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fpnp%2Fpnpbios%2Fcore.c;h=a8a51500e1e9aae008cfc1cddc9ef547f4b6e10e;hb=52833e897fd8c6f62b3e5e27291fa9bc803f7460;hp=4e9fd37cff35ca3f8ad925d069a32f5aa72518d6;hpb=df3d80f5a5c74168be42788364d13cf6c83c7b9c;p=linux-2.6 diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c index 4e9fd37cff..a8a51500e1 100644 --- a/drivers/pnp/pnpbios/core.c +++ b/drivers/pnp/pnpbios/core.c @@ -105,8 +105,6 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info) char *argv[3], **envp, *buf, *scratch; int i = 0, value; - if (!current->fs->root) - return -EAGAIN; if (!(envp = kcalloc(20, sizeof(char *), GFP_KERNEL))) return -ENOMEM; if (!(buf = kzalloc(256, GFP_KERNEL))) { @@ -315,25 +313,31 @@ struct pnp_protocol pnpbios_protocol = { .disable = pnpbios_disable_resources, }; -static int insert_device(struct pnp_dev *dev, struct pnp_bios_node *node) +static int __init insert_device(struct pnp_bios_node *node) { struct list_head *pos; - struct pnp_dev *pnp_dev; + struct pnp_dev *dev; struct pnp_id *dev_id; char id[8]; /* check if the device is already added */ - dev->number = node->handle; list_for_each(pos, &pnpbios_protocol.devices) { - pnp_dev = list_entry(pos, struct pnp_dev, protocol_list); - if (dev->number == pnp_dev->number) + dev = list_entry(pos, struct pnp_dev, protocol_list); + if (dev->number == node->handle) return -1; } - /* set the initial values for the PnP device */ + dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); + if (!dev) + return -1; + dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); - if (!dev_id) + if (!dev_id) { + kfree(dev); return -1; + } + + dev->number = node->handle; pnpid32_to_pnpid(node->eisa_id, id); memcpy(dev_id->id, id, 7); pnp_add_id(dev_id, dev); @@ -367,7 +371,6 @@ static void __init build_devlist(void) unsigned int nodes_got = 0; unsigned int devs = 0; struct pnp_bios_node *node; - struct pnp_dev *dev; node = kzalloc(node_info.max_node_size, GFP_KERNEL); if (!node) @@ -388,12 +391,7 @@ static void __init build_devlist(void) break; } nodes_got++; - dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); - if (!dev) - break; - if (insert_device(dev, node) < 0) - kfree(dev); - else + if (insert_device(node) == 0) devs++; if (nodenum <= thisnodenum) { printk(KERN_ERR