aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/net.c
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2013-03-07 20:43:55 -0500
committerStefan Richter <stefanr@s5r6.in-berlin.de>2013-03-13 11:11:12 -0400
commiteac31d58ca2818e3fdc7a6e78fa1b56965f604e9 (patch)
tree52319b8b9810c19834e9ba228eb17bb805bd1bfa /drivers/firewire/net.c
parentd9d2b484e0006d51591c3b9594e9d5f73b1a8d08 (diff)
firewire net: Allocate dev->broadcast_rcv_buffer_ptrs early.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire/net.c')
-rw-r--r--drivers/firewire/net.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 0dc2fdf00562..21210fb94762 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -1163,6 +1163,13 @@ static int fwnet_broadcast_start(struct fwnet_device *dev)
1163 max_receive = 1U << (dev->card->max_receive + 1); 1163 max_receive = 1U << (dev->card->max_receive + 1);
1164 num_packets = (FWNET_ISO_PAGE_COUNT * PAGE_SIZE) / max_receive; 1164 num_packets = (FWNET_ISO_PAGE_COUNT * PAGE_SIZE) / max_receive;
1165 1165
1166 ptrptr = kmalloc(sizeof(void *) * num_packets, GFP_KERNEL);
1167 if (!ptrptr) {
1168 retval = -ENOMEM;
1169 goto failed_ptrs_alloc;
1170 }
1171 dev->broadcast_rcv_buffer_ptrs = ptrptr;
1172
1166 context = fw_iso_context_create(dev->card, FW_ISO_CONTEXT_RECEIVE, 1173 context = fw_iso_context_create(dev->card, FW_ISO_CONTEXT_RECEIVE,
1167 IEEE1394_BROADCAST_CHANNEL, 1174 IEEE1394_BROADCAST_CHANNEL,
1168 dev->card->link_speed, 8, 1175 dev->card->link_speed, 8,
@@ -1177,13 +1184,6 @@ static int fwnet_broadcast_start(struct fwnet_device *dev)
1177 if (retval < 0) 1184 if (retval < 0)
1178 goto failed_buffer_init; 1185 goto failed_buffer_init;
1179 1186
1180 ptrptr = kmalloc(sizeof(void *) * num_packets, GFP_KERNEL);
1181 if (!ptrptr) {
1182 retval = -ENOMEM;
1183 goto failed_ptrs_alloc;
1184 }
1185
1186 dev->broadcast_rcv_buffer_ptrs = ptrptr;
1187 for (u = 0; u < FWNET_ISO_PAGE_COUNT; u++) { 1187 for (u = 0; u < FWNET_ISO_PAGE_COUNT; u++) {
1188 void *ptr; 1188 void *ptr;
1189 unsigned v; 1189 unsigned v;
@@ -1226,16 +1226,16 @@ static int fwnet_broadcast_start(struct fwnet_device *dev)
1226 return 0; 1226 return 0;
1227 1227
1228 failed_rcv_queue: 1228 failed_rcv_queue:
1229 kfree(dev->broadcast_rcv_buffer_ptrs);
1230 dev->broadcast_rcv_buffer_ptrs = NULL;
1231 for (u = 0; u < FWNET_ISO_PAGE_COUNT; u++) 1229 for (u = 0; u < FWNET_ISO_PAGE_COUNT; u++)
1232 kunmap(dev->broadcast_rcv_buffer.pages[u]); 1230 kunmap(dev->broadcast_rcv_buffer.pages[u]);
1233 failed_ptrs_alloc:
1234 fw_iso_buffer_destroy(&dev->broadcast_rcv_buffer, dev->card); 1231 fw_iso_buffer_destroy(&dev->broadcast_rcv_buffer, dev->card);
1235 failed_buffer_init: 1232 failed_buffer_init:
1236 fw_iso_context_destroy(context); 1233 fw_iso_context_destroy(context);
1237 dev->broadcast_rcv_context = NULL; 1234 dev->broadcast_rcv_context = NULL;
1238 failed_context_create: 1235 failed_context_create:
1236 kfree(dev->broadcast_rcv_buffer_ptrs);
1237 dev->broadcast_rcv_buffer_ptrs = NULL;
1238 failed_ptrs_alloc:
1239 1239
1240 return retval; 1240 return retval;
1241} 1241}
@@ -1626,8 +1626,6 @@ static int fwnet_remove(struct device *_dev)
1626 1626
1627 fw_iso_context_stop(dev->broadcast_rcv_context); 1627 fw_iso_context_stop(dev->broadcast_rcv_context);
1628 1628
1629 kfree(dev->broadcast_rcv_buffer_ptrs);
1630 dev->broadcast_rcv_buffer_ptrs = NULL;
1631 for (u = 0; u < FWNET_ISO_PAGE_COUNT; u++) 1629 for (u = 0; u < FWNET_ISO_PAGE_COUNT; u++)
1632 kunmap(dev->broadcast_rcv_buffer.pages[u]); 1630 kunmap(dev->broadcast_rcv_buffer.pages[u]);
1633 1631
@@ -1635,6 +1633,8 @@ static int fwnet_remove(struct device *_dev)
1635 dev->card); 1633 dev->card);
1636 fw_iso_context_destroy(dev->broadcast_rcv_context); 1634 fw_iso_context_destroy(dev->broadcast_rcv_context);
1637 dev->broadcast_rcv_context = NULL; 1635 dev->broadcast_rcv_context = NULL;
1636 kfree(dev->broadcast_rcv_buffer_ptrs);
1637 dev->broadcast_rcv_buffer_ptrs = NULL;
1638 dev->broadcast_state = FWNET_BROADCAST_ERROR; 1638 dev->broadcast_state = FWNET_BROADCAST_ERROR;
1639 } 1639 }
1640 for (i = 0; dev->queued_datagrams && i < 5; i++) 1640 for (i = 0; dev->queued_datagrams && i < 5; i++)