[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [linux-2.6.18-xen] pciback: Avoid large array allocation on kernel stack.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1220706882 -3600
# Node ID 67ff2b5a88ec1873ef0ed698dc701640fbbbfd6f
# Parent  ad374a7a9f3ed6417ffa9ba9590e056d67081985
pciback: Avoid large array allocation on kernel stack.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 drivers/xen/pciback/conf_space_capability_msi.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff -r ad374a7a9f3e -r 67ff2b5a88ec 
drivers/xen/pciback/conf_space_capability_msi.c
--- a/drivers/xen/pciback/conf_space_capability_msi.c   Fri Sep 05 12:39:29 
2008 +0100
+++ b/drivers/xen/pciback/conf_space_capability_msi.c   Sat Sep 06 14:14:42 
2008 +0100
@@ -2,6 +2,7 @@
  * PCI Backend -- Configuration overlay for MSI capability
  */
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include "conf_space.h"
 #include "conf_space_capability.h"
 #include <xen/interface/io/pciif.h>
@@ -37,12 +38,15 @@ int pciback_enable_msix(struct pciback_d
 int pciback_enable_msix(struct pciback_device *pdev,
                struct pci_dev *dev, struct xen_pci_op *op)
 {
-       int i;
-       int result;
-       struct msix_entry entries[op->value];
+       int i, result;
+       struct msix_entry *entries;
 
        if (op->value > SH_INFO_MAX_VEC)
                return -EINVAL;
+
+       entries = kmalloc(op->value * sizeof(*entries));
+       if (entries == NULL)
+               return -ENOMEM;
 
        for (i = 0; i < op->value; i++) {
                entries[i].entry = op->msix_entries[i].entry;
@@ -55,6 +59,8 @@ int pciback_enable_msix(struct pciback_d
                op->msix_entries[i].entry = entries[i].entry;
                op->msix_entries[i].vector = entries[i].vector;
        }
+
+       kfree(entries);
 
        op->value = result;
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.