aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-10-01 16:17:44 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-01 16:17:44 -0400
commitd834c16516d1ebec4766fc58c059bf01311e6045 (patch)
tree8095561ebb7b01bd21e1f6ca548a3ea0b2bca675
parent4e9011d50d77ce7d234272e203235d8ecffd61a1 (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>
-rw-r--r--drivers/pcmcia/socket_sysfs.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index c5d7476da471..933cd864a5c9 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
298{ 298{
299 struct pcmcia_socket *s = to_socket(container_of(kobj, struct class_device, kobj)); 299 struct pcmcia_socket *s = to_socket(container_of(kobj, struct class_device, kobj));
300 cisdump_t *cis; 300 cisdump_t *cis;
301 ssize_t ret = count; 301 int error;
302 302
303 if (off) 303 if (off)
304 return -EINVAL; 304 return -EINVAL;
@@ -316,25 +316,22 @@ static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, siz
316 cis->Length = count + 1; 316 cis->Length = count + 1;
317 memcpy(cis->Data, buf, count); 317 memcpy(cis->Data, buf, count);
318 318
319 if (pcmcia_replace_cis(s, cis)) 319 error = pcmcia_replace_cis(s, cis);
320 ret = -EIO;
321
322 kfree(cis); 320 kfree(cis);
321 if (error)
322 return -EIO;
323 323
324 if (!ret) { 324 mutex_lock(&s->skt_mutex);
325 mutex_lock(&s->skt_mutex); 325 if ((s->callback) && (s->state & SOCKET_PRESENT) &&
326 if ((s->callback) && (s->state & SOCKET_PRESENT) && 326 !(s->state & SOCKET_CARDBUS)) {
327 !(s->state & SOCKET_CARDBUS)) { 327 if (try_module_get(s->callback->owner)) {
328 if (try_module_get(s->callback->owner)) { 328 s->callback->requery(s);
329 s->callback->requery(s); 329 module_put(s->callback->owner);
330 module_put(s->callback->owner);
331 }
332 } 330 }
333 mutex_unlock(&s->skt_mutex);
334 } 331 }
332 mutex_unlock(&s->skt_mutex);
335 333
336 334 return count;
337 return (ret);
338} 335}
339 336
340 337