Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] PNP: handle sysfs errors

Signed-off-by: Jeff Garzik <jeff@garzik.org>
Cc: Adam Belay <ambx1@neo.rr.com>
Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Jeff Garzik and committed by
Linus Torvalds
bfc7ee20 3889b26b

+35 -12
+21 -9
drivers/pnp/card.c
··· 164 164 165 165 static int pnp_interface_attach_card(struct pnp_card *card) 166 166 { 167 - device_create_file(&card->dev,&dev_attr_name); 168 - device_create_file(&card->dev,&dev_attr_card_id); 167 + int rc = device_create_file(&card->dev,&dev_attr_name); 168 + if (rc) return rc; 169 + 170 + rc = device_create_file(&card->dev,&dev_attr_card_id); 171 + if (rc) goto err_name; 172 + 169 173 return 0; 174 + 175 + err_name: 176 + device_remove_file(&card->dev,&dev_attr_name); 177 + return rc; 170 178 } 171 179 172 180 /** ··· 314 306 down_write(&dev->dev.bus->subsys.rwsem); 315 307 dev->card_link = clink; 316 308 dev->dev.driver = &drv->link.driver; 317 - if (pnp_bus_type.probe(&dev->dev)) { 318 - dev->dev.driver = NULL; 319 - dev->card_link = NULL; 320 - up_write(&dev->dev.bus->subsys.rwsem); 321 - return NULL; 322 - } 323 - device_bind_driver(&dev->dev); 309 + if (pnp_bus_type.probe(&dev->dev)) 310 + goto err_out; 311 + if (device_bind_driver(&dev->dev)) 312 + goto err_out; 313 + 324 314 up_write(&dev->dev.bus->subsys.rwsem); 325 315 326 316 return dev; 317 + 318 + err_out: 319 + dev->dev.driver = NULL; 320 + dev->card_link = NULL; 321 + up_write(&dev->dev.bus->subsys.rwsem); 322 + return NULL; 327 323 } 328 324 329 325 /**
+14 -3
drivers/pnp/interface.c
··· 461 461 462 462 int pnp_interface_attach_device(struct pnp_dev *dev) 463 463 { 464 - device_create_file(&dev->dev,&dev_attr_options); 465 - device_create_file(&dev->dev,&dev_attr_resources); 466 - device_create_file(&dev->dev,&dev_attr_id); 464 + int rc = device_create_file(&dev->dev,&dev_attr_options); 465 + if (rc) goto err; 466 + rc = device_create_file(&dev->dev,&dev_attr_resources); 467 + if (rc) goto err_opt; 468 + rc = device_create_file(&dev->dev,&dev_attr_id); 469 + if (rc) goto err_res; 470 + 467 471 return 0; 472 + 473 + err_res: 474 + device_remove_file(&dev->dev,&dev_attr_resources); 475 + err_opt: 476 + device_remove_file(&dev->dev,&dev_attr_options); 477 + err: 478 + return rc; 468 479 }