Commit a230a678 authored by Om Narasimhan's avatar Om Narasimhan Committed by Dominik Brodowski

[PATCH] pcmcia: au1000_generic fix

The previous code did something like,

if (error) goto out_err;
....
do {
             struct au1000_pcmcia_socket *skt = PCMCIA_SOCKET(i);
              del_timer_sync(&skt->poll_timer);
               pcmcia_unregister_socket(&skt->socket);
out_err:
               flush_scheduled_work();
               ops->hw_shutdown(skt);
               i--;
} while (i > 0)
.....

- On the error path, skt would not contain a valid value for the first
  iteration (skt is masked by uninitialized automatic skt)

- Does not do hw_shutdown() for 0th element of PCMCIA_SOCKET
Signed-off-by: default avatarOm Narasimhan <om.turyx@gmail.com>
Cc: "Yoichi Yuasa" <yoichi_yuasa@tripeaks.co.jp>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent f465ce17
...@@ -351,6 +351,7 @@ struct skt_dev_info { ...@@ -351,6 +351,7 @@ struct skt_dev_info {
int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr) int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr)
{ {
struct skt_dev_info *sinfo; struct skt_dev_info *sinfo;
struct au1000_pcmcia_socket *skt;
int ret, i; int ret, i;
sinfo = kzalloc(sizeof(struct skt_dev_info), GFP_KERNEL); sinfo = kzalloc(sizeof(struct skt_dev_info), GFP_KERNEL);
...@@ -365,7 +366,7 @@ int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops, ...@@ -365,7 +366,7 @@ int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops,
* Initialise the per-socket structure. * Initialise the per-socket structure.
*/ */
for (i = 0; i < nr; i++) { for (i = 0; i < nr; i++) {
struct au1000_pcmcia_socket *skt = PCMCIA_SOCKET(i); skt = PCMCIA_SOCKET(i);
memset(skt, 0, sizeof(*skt)); memset(skt, 0, sizeof(*skt));
skt->socket.resource_ops = &pccard_static_ops; skt->socket.resource_ops = &pccard_static_ops;
...@@ -438,17 +439,19 @@ int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops, ...@@ -438,17 +439,19 @@ int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops,
dev_set_drvdata(dev, sinfo); dev_set_drvdata(dev, sinfo);
return 0; return 0;
do {
struct au1000_pcmcia_socket *skt = PCMCIA_SOCKET(i); out_err:
flush_scheduled_work();
ops->hw_shutdown(skt);
while (i-- > 0) {
skt = PCMCIA_SOCKET(i);
del_timer_sync(&skt->poll_timer); del_timer_sync(&skt->poll_timer);
pcmcia_unregister_socket(&skt->socket); pcmcia_unregister_socket(&skt->socket);
out_err:
flush_scheduled_work(); flush_scheduled_work();
ops->hw_shutdown(skt); ops->hw_shutdown(skt);
i--; }
} while (i > 0);
kfree(sinfo); kfree(sinfo);
out: out:
return ret; return ret;
......
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