diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-01 13:17:44 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-01 13:17:44 -0700 |
commit | d834c16516d1ebec4766fc58c059bf01311e6045 (patch) | |
tree | 8095561ebb7b01bd21e1f6ca548a3ea0b2bca675 /drivers/pcmcia | |
parent | 4e9011d50d77ce7d234272e203235d8ecffd61a1 (diff) |
pccard_store_cis: fix wrong error handling
The test for the error from pcmcia_replace_cis() was incorrect, and
would always trigger (because if an error didn't happen, the "ret" value
would not be zero, it would be the passed-in count).
Reported and debugged by Fabrice Bellet <fabrice@bellet.info>
Rather than just fix the single broken test, make the code in question
use an understandable code-sequence instead, fixing the whole function
to be more readable.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r-- | drivers/pcmcia/socket_sysfs.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c index c5d7476da47..933cd864a5c 100644 --- a/drivers/pcmcia/socket_sysfs.c +++ b/drivers/pcmcia/socket_sysfs.c @@ -298,7 +298,7 @@ static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, siz { struct pcmcia_socket *s = to_socket(container_of(kobj, struct class_device, kobj)); cisdump_t *cis; - ssize_t ret = count; + int error; if (off) return -EINVAL; @@ -316,25 +316,22 @@ static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, siz cis->Length = count + 1; memcpy(cis->Data, buf, count); - if (pcmcia_replace_cis(s, cis)) - ret = -EIO; - + error = pcmcia_replace_cis(s, cis); kfree(cis); + if (error) + return -EIO; - if (!ret) { - mutex_lock(&s->skt_mutex); - if ((s->callback) && (s->state & SOCKET_PRESENT) && - !(s->state & SOCKET_CARDBUS)) { - if (try_module_get(s->callback->owner)) { - s->callback->requery(s); - module_put(s->callback->owner); - } + mutex_lock(&s->skt_mutex); + if ((s->callback) && (s->state & SOCKET_PRESENT) && + !(s->state & SOCKET_CARDBUS)) { + if (try_module_get(s->callback->owner)) { + s->callback->requery(s); + module_put(s->callback->owner); } - mutex_unlock(&s->skt_mutex); } + mutex_unlock(&s->skt_mutex); - - return (ret); + return count; } |