aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/xen-netback/netback.c
diff options
context:
space:
mode:
authorWei Liu <wei.liu2@citrix.com>2013-05-01 20:43:58 -0400
committerDavid S. Miller <davem@davemloft.net>2013-05-02 16:50:08 -0400
commit59ccb4ebbc35e36a3c143f2d1355deb75c2e628f (patch)
tree7c93d18c8162dc66538064676d30f76a1fbc0714 /drivers/net/xen-netback/netback.c
parentac69c26e7accb04ae2cb9ab0872068983a42b3c8 (diff)
xen-netback: avoid allocating variable size array on stack
Tune xen_netbk_count_requests to not touch working array beyond limit, so that we can make working array size constant. Suggested-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/xen-netback/netback.c')
-rw-r--r--drivers/net/xen-netback/netback.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index c44772d6bba0..ce8109f7d56f 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -934,11 +934,14 @@ static int netbk_count_requests(struct xenvif *vif,
934 RING_IDX cons = vif->tx.req_cons; 934 RING_IDX cons = vif->tx.req_cons;
935 int slots = 0; 935 int slots = 0;
936 int drop_err = 0; 936 int drop_err = 0;
937 int more_data;
937 938
938 if (!(first->flags & XEN_NETTXF_more_data)) 939 if (!(first->flags & XEN_NETTXF_more_data))
939 return 0; 940 return 0;
940 941
941 do { 942 do {
943 struct xen_netif_tx_request dropped_tx = { 0 };
944
942 if (slots >= work_to_do) { 945 if (slots >= work_to_do) {
943 netdev_err(vif->dev, 946 netdev_err(vif->dev,
944 "Asked for %d slots but exceeds this limit\n", 947 "Asked for %d slots but exceeds this limit\n",
@@ -972,6 +975,9 @@ static int netbk_count_requests(struct xenvif *vif,
972 drop_err = -E2BIG; 975 drop_err = -E2BIG;
973 } 976 }
974 977
978 if (drop_err)
979 txp = &dropped_tx;
980
975 memcpy(txp, RING_GET_REQUEST(&vif->tx, cons + slots), 981 memcpy(txp, RING_GET_REQUEST(&vif->tx, cons + slots),
976 sizeof(*txp)); 982 sizeof(*txp));
977 983
@@ -1001,7 +1007,13 @@ static int netbk_count_requests(struct xenvif *vif,
1001 netbk_fatal_tx_err(vif); 1007 netbk_fatal_tx_err(vif);
1002 return -EINVAL; 1008 return -EINVAL;
1003 } 1009 }
1004 } while ((txp++)->flags & XEN_NETTXF_more_data); 1010
1011 more_data = txp->flags & XEN_NETTXF_more_data;
1012
1013 if (!drop_err)
1014 txp++;
1015
1016 } while (more_data);
1005 1017
1006 if (drop_err) { 1018 if (drop_err) {
1007 netbk_tx_err(vif, first, cons + slots); 1019 netbk_tx_err(vif, first, cons + slots);
@@ -1408,7 +1420,7 @@ static unsigned xen_netbk_tx_build_gops(struct xen_netbk *netbk)
1408 !list_empty(&netbk->net_schedule_list)) { 1420 !list_empty(&netbk->net_schedule_list)) {
1409 struct xenvif *vif; 1421 struct xenvif *vif;
1410 struct xen_netif_tx_request txreq; 1422 struct xen_netif_tx_request txreq;
1411 struct xen_netif_tx_request txfrags[max_skb_slots]; 1423 struct xen_netif_tx_request txfrags[XEN_NETIF_NR_SLOTS_MIN];
1412 struct page *page; 1424 struct page *page;
1413 struct xen_netif_extra_info extras[XEN_NETIF_EXTRA_TYPE_MAX-1]; 1425 struct xen_netif_extra_info extras[XEN_NETIF_EXTRA_TYPE_MAX-1];
1414 u16 pending_idx; 1426 u16 pending_idx;