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>
This commit is contained in:
parent
4e9011d50d
commit
d834c16516
1 changed files with 12 additions and 15 deletions
|
@ -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));
|
struct pcmcia_socket *s = to_socket(container_of(kobj, struct class_device, kobj));
|
||||||
cisdump_t *cis;
|
cisdump_t *cis;
|
||||||
ssize_t ret = count;
|
int error;
|
||||||
|
|
||||||
if (off)
|
if (off)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -316,12 +316,11 @@ static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, siz
|
||||||
cis->Length = count + 1;
|
cis->Length = count + 1;
|
||||||
memcpy(cis->Data, buf, count);
|
memcpy(cis->Data, buf, count);
|
||||||
|
|
||||||
if (pcmcia_replace_cis(s, cis))
|
error = pcmcia_replace_cis(s, cis);
|
||||||
ret = -EIO;
|
|
||||||
|
|
||||||
kfree(cis);
|
kfree(cis);
|
||||||
|
if (error)
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
if (!ret) {
|
|
||||||
mutex_lock(&s->skt_mutex);
|
mutex_lock(&s->skt_mutex);
|
||||||
if ((s->callback) && (s->state & SOCKET_PRESENT) &&
|
if ((s->callback) && (s->state & SOCKET_PRESENT) &&
|
||||||
!(s->state & SOCKET_CARDBUS)) {
|
!(s->state & SOCKET_CARDBUS)) {
|
||||||
|
@ -331,10 +330,8 @@ static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, siz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mutex_unlock(&s->skt_mutex);
|
mutex_unlock(&s->skt_mutex);
|
||||||
}
|
|
||||||
|
|
||||||
|
return count;
|
||||||
return (ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue