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