Commit bfc7ee207078e8ca51264355805e6f56b485be4b

Authored by Jeff Garzik
Committed by Linus Torvalds
1 parent 3889b26beb

[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>

Showing 2 changed files with 35 additions and 12 deletions Side-by-side Diff

... ... @@ -164,9 +164,17 @@
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 /**
173 181  
... ... @@ -306,16 +314,20 @@
306 314 down_write(&dev->dev.bus->subsys.rwsem);
307 315 dev->card_link = clink;
308 316 dev->dev.driver = &drv->link.driver;
309   - if (pnp_bus_type.probe(&dev->dev)) {
310   - dev->dev.driver = NULL;
311   - dev->card_link = NULL;
312   - up_write(&dev->dev.bus->subsys.rwsem);
313   - return NULL;
314   - }
315   - device_bind_driver(&dev->dev);
  317 + if (pnp_bus_type.probe(&dev->dev))
  318 + goto err_out;
  319 + if (device_bind_driver(&dev->dev))
  320 + goto err_out;
  321 +
316 322 up_write(&dev->dev.bus->subsys.rwsem);
317 323  
318 324 return dev;
  325 +
  326 +err_out:
  327 + dev->dev.driver = NULL;
  328 + dev->card_link = NULL;
  329 + up_write(&dev->dev.bus->subsys.rwsem);
  330 + return NULL;
319 331 }
320 332  
321 333 /**
drivers/pnp/interface.c
... ... @@ -461,9 +461,20 @@
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 }