aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2012-12-14 10:01:08 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-17 15:07:34 -0500
commit36c286d5a45731d957d02c317ee2ce775e856765 (patch)
tree778868e251f4f6bb1c1e22bdd203e2ccb04d0054
parent7353f85ce82baa363b0338ef4cb3745eb0686760 (diff)
pcmcia: i82092: fix i82092aa_pci_remove()
Smatch complains because the call to pci_set_drvdata(dev, &sockets[i].socket); is reading one step beyond the end of the sockets[] array. It will crash when we use it later. The only place which uses pci_get_drvdata() is i82092aa_pci_remove(). That function should loop through all the sockets and unregister them. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/pcmcia/i82092.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c
index 3578e1ca97a0..519c4d6003a6 100644
--- a/drivers/pcmcia/i82092.c
+++ b/drivers/pcmcia/i82092.c
@@ -133,8 +133,6 @@ static int i82092aa_pci_probe(struct pci_dev *dev, const struct pci_device_id *i
133 goto err_out_free_res; 133 goto err_out_free_res;
134 } 134 }
135 135
136 pci_set_drvdata(dev, &sockets[i].socket);
137
138 for (i = 0; i<socket_count; i++) { 136 for (i = 0; i<socket_count; i++) {
139 sockets[i].socket.dev.parent = &dev->dev; 137 sockets[i].socket.dev.parent = &dev->dev;
140 sockets[i].socket.ops = &i82092aa_operations; 138 sockets[i].socket.ops = &i82092aa_operations;
@@ -164,14 +162,14 @@ err_out_disable:
164 162
165static void i82092aa_pci_remove(struct pci_dev *dev) 163static void i82092aa_pci_remove(struct pci_dev *dev)
166{ 164{
167 struct pcmcia_socket *socket = pci_get_drvdata(dev); 165 int i;
168 166
169 enter("i82092aa_pci_remove"); 167 enter("i82092aa_pci_remove");
170 168
171 free_irq(dev->irq, i82092aa_interrupt); 169 free_irq(dev->irq, i82092aa_interrupt);
172 170
173 if (socket) 171 for (i = 0; i < socket_count; i++)
174 pcmcia_unregister_socket(socket); 172 pcmcia_unregister_socket(&sockets[i].socket);
175 173
176 leave("i82092aa_pci_remove"); 174 leave("i82092aa_pci_remove");
177} 175}