Commit 4b991da7 authored by Thibaut VARENE's avatar Thibaut VARENE Committed by Kyle McMartin

[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: default avatarThibaut VARENE <varenet@parisc-linux.org>
Signed-off-by: default avatarKyle McMartin <kyle@parisc-linux.org>
parent 9b9ff2e1
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/hardware.h> #include <asm/hardware.h>
#define PDCS_VERSION "0.09" #define PDCS_VERSION "0.10"
#define PDCS_ADDR_PPRI 0x00 #define PDCS_ADDR_PPRI 0x00
#define PDCS_ADDR_OSID 0x40 #define PDCS_ADDR_OSID 0x40
...@@ -194,7 +194,8 @@ pdcspath_store(struct pdcspath_entry *entry) ...@@ -194,7 +194,8 @@ pdcspath_store(struct pdcspath_entry *entry)
return -EIO; return -EIO;
} }
entry->ready = 1; /* kobject is already registered */
entry->ready = 2;
DPRINTK("%s: device: 0x%p\n", __func__, entry->dev); DPRINTK("%s: device: 0x%p\n", __func__, entry->dev);
...@@ -653,15 +654,21 @@ pdcs_register_pathentries(void) ...@@ -653,15 +654,21 @@ pdcs_register_pathentries(void)
{ {
unsigned short i; unsigned short i;
struct pdcspath_entry *entry; struct pdcspath_entry *entry;
int err;
for (i = 0; (entry = pdcspath_entries[i]); i++) { for (i = 0; (entry = pdcspath_entries[i]); i++) {
if (pdcspath_fetch(entry) < 0) if (pdcspath_fetch(entry) < 0)
continue; continue;
kobject_set_name(&entry->kobj, "%s", entry->name); if ((err = kobject_set_name(&entry->kobj, "%s", entry->name)))
return err;
kobj_set_kset_s(entry, paths_subsys); kobj_set_kset_s(entry, paths_subsys);
kobject_register(&entry->kobj); if ((err = kobject_register(&entry->kobj)))
return err;
/* kobject is now registered */
entry->ready = 2;
if (!entry->dev) if (!entry->dev)
continue; continue;
...@@ -675,14 +682,14 @@ pdcs_register_pathentries(void) ...@@ -675,14 +682,14 @@ pdcs_register_pathentries(void)
/** /**
* pdcs_unregister_pathentries - Routine called when unregistering the module. * pdcs_unregister_pathentries - Routine called when unregistering the module.
*/ */
static inline void __exit static inline void
pdcs_unregister_pathentries(void) pdcs_unregister_pathentries(void)
{ {
unsigned short i; unsigned short i;
struct pdcspath_entry *entry; struct pdcspath_entry *entry;
for (i = 0; (entry = pdcspath_entries[i]); i++) for (i = 0; (entry = pdcspath_entries[i]); i++)
if (entry->ready) if (entry->ready >= 2)
kobject_unregister(&entry->kobj); kobject_unregister(&entry->kobj);
} }
...@@ -704,7 +711,7 @@ pdc_stable_init(void) ...@@ -704,7 +711,7 @@ pdc_stable_init(void)
/* For now we'll register the pdc subsys within this driver */ /* For now we'll register the pdc subsys within this driver */
if ((rc = firmware_register(&pdc_subsys))) if ((rc = firmware_register(&pdc_subsys)))
return rc; goto fail_firmreg;
/* Don't forget the info entry */ /* Don't forget the info entry */
for (i = 0; (attr = pdcs_subsys_attrs[i]) && !error; i++) for (i = 0; (attr = pdcs_subsys_attrs[i]) && !error; i++)
...@@ -713,12 +720,25 @@ pdc_stable_init(void) ...@@ -713,12 +720,25 @@ pdc_stable_init(void)
/* register the paths subsys as a subsystem of pdc subsys */ /* register the paths subsys as a subsystem of pdc subsys */
kset_set_kset_s(&paths_subsys, pdc_subsys); kset_set_kset_s(&paths_subsys, pdc_subsys);
subsystem_register(&paths_subsys); if ((rc= subsystem_register(&paths_subsys)))
goto fail_subsysreg;
/* now we create all "files" for the paths subsys */ /* now we create all "files" for the paths subsys */
pdcs_register_pathentries(); if ((rc = pdcs_register_pathentries()))
goto fail_pdcsreg;
return rc;
return 0; fail_pdcsreg:
pdcs_unregister_pathentries();
subsystem_unregister(&paths_subsys);
fail_subsysreg:
firmware_unregister(&pdc_subsys);
fail_firmreg:
printk(KERN_INFO "PDC Stable Storage bailing out\n");
return rc;
} }
static void __exit static void __exit
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment