[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: Om Narasimhan <om.turyx@gmail.com>
Cc: "Yoichi Yuasa" <yoichi_yuasa@tripeaks.co.jp>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>

authored by Om Narasimhan and committed by Dominik Brodowski a230a678 f465ce17

+9 -6
+9 -6
drivers/pcmcia/au1000_generic.c
··· 351 351 int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr) 352 352 { 353 353 struct skt_dev_info *sinfo; 354 + struct au1000_pcmcia_socket *skt; 354 355 int ret, i; 355 356 356 357 sinfo = kzalloc(sizeof(struct skt_dev_info), GFP_KERNEL); ··· 366 365 * Initialise the per-socket structure. 367 366 */ 368 367 for (i = 0; i < nr; i++) { 369 - struct au1000_pcmcia_socket *skt = PCMCIA_SOCKET(i); 368 + skt = PCMCIA_SOCKET(i); 370 369 memset(skt, 0, sizeof(*skt)); 371 370 372 371 skt->socket.resource_ops = &pccard_static_ops; ··· 439 438 dev_set_drvdata(dev, sinfo); 440 439 return 0; 441 440 442 - do { 443 - struct au1000_pcmcia_socket *skt = PCMCIA_SOCKET(i); 441 + 442 + out_err: 443 + flush_scheduled_work(); 444 + ops->hw_shutdown(skt); 445 + while (i-- > 0) { 446 + skt = PCMCIA_SOCKET(i); 444 447 445 448 del_timer_sync(&skt->poll_timer); 446 449 pcmcia_unregister_socket(&skt->socket); 447 - out_err: 448 450 flush_scheduled_work(); 449 451 ops->hw_shutdown(skt); 450 452 451 - i--; 452 - } while (i > 0); 453 + } 453 454 kfree(sinfo); 454 455 out: 455 456 return ret;