[PARISC] pdc_stable: More robust sysfs error checking

pdc_stable 0.10:
As mentioned on LKML, pdc_stable wasn't checky enough on the return
values of some calls. This patch makes it more robust to errors when
registering objects in sysfs.

Signed-off-by: Thibaut VARENE <varenet@parisc-linux.org>
Signed-off-by: Kyle McMartin <kyle@parisc-linux.org>

authored by

Thibaut VARENE and committed by
Kyle McMartin
4b991da7 9b9ff2e1

+31 -11
+31 -11
drivers/parisc/pdc_stable.c
··· 56 56 #include <asm/uaccess.h> 57 57 #include <asm/hardware.h> 58 58 59 - #define PDCS_VERSION "0.09" 59 + #define PDCS_VERSION "0.10" 60 60 61 61 #define PDCS_ADDR_PPRI 0x00 62 62 #define PDCS_ADDR_OSID 0x40 ··· 194 194 return -EIO; 195 195 } 196 196 197 - entry->ready = 1; 197 + /* kobject is already registered */ 198 + entry->ready = 2; 198 199 199 200 DPRINTK("%s: device: 0x%p\n", __func__, entry->dev); 200 201 ··· 654 653 { 655 654 unsigned short i; 656 655 struct pdcspath_entry *entry; 656 + int err; 657 657 658 658 for (i = 0; (entry = pdcspath_entries[i]); i++) { 659 659 if (pdcspath_fetch(entry) < 0) 660 660 continue; 661 661 662 - kobject_set_name(&entry->kobj, "%s", entry->name); 662 + if ((err = kobject_set_name(&entry->kobj, "%s", entry->name))) 663 + return err; 663 664 kobj_set_kset_s(entry, paths_subsys); 664 - kobject_register(&entry->kobj); 665 - 665 + if ((err = kobject_register(&entry->kobj))) 666 + return err; 667 + 668 + /* kobject is now registered */ 669 + entry->ready = 2; 670 + 666 671 if (!entry->dev) 667 672 continue; 668 673 ··· 682 675 /** 683 676 * pdcs_unregister_pathentries - Routine called when unregistering the module. 684 677 */ 685 - static inline void __exit 678 + static inline void 686 679 pdcs_unregister_pathentries(void) 687 680 { 688 681 unsigned short i; 689 682 struct pdcspath_entry *entry; 690 683 691 684 for (i = 0; (entry = pdcspath_entries[i]); i++) 692 - if (entry->ready) 685 + if (entry->ready >= 2) 693 686 kobject_unregister(&entry->kobj); 694 687 } 695 688 ··· 711 704 712 705 /* For now we'll register the pdc subsys within this driver */ 713 706 if ((rc = firmware_register(&pdc_subsys))) 714 - return rc; 707 + goto fail_firmreg; 715 708 716 709 /* Don't forget the info entry */ 717 710 for (i = 0; (attr = pdcs_subsys_attrs[i]) && !error; i++) ··· 720 713 721 714 /* register the paths subsys as a subsystem of pdc subsys */ 722 715 kset_set_kset_s(&paths_subsys, pdc_subsys); 723 - subsystem_register(&paths_subsys); 716 + if ((rc= subsystem_register(&paths_subsys))) 717 + goto fail_subsysreg; 724 718 725 719 /* now we create all "files" for the paths subsys */ 726 - pdcs_register_pathentries(); 720 + if ((rc = pdcs_register_pathentries())) 721 + goto fail_pdcsreg; 722 + 723 + return rc; 727 724 728 - return 0; 725 + fail_pdcsreg: 726 + pdcs_unregister_pathentries(); 727 + subsystem_unregister(&paths_subsys); 728 + 729 + fail_subsysreg: 730 + firmware_unregister(&pdc_subsys); 731 + 732 + fail_firmreg: 733 + printk(KERN_INFO "PDC Stable Storage bailing out\n"); 734 + return rc; 729 735 } 730 736 731 737 static void __exit