ia64/linux-2.6.18-xen.hg

changeset 660:67ff2b5a88ec

pciback: Avoid large array allocation on kernel stack.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Sat Sep 06 14:14:42 2008 +0100 (2008-09-06)
parents ad374a7a9f3e
children 7886619f623e
files drivers/xen/pciback/conf_space_capability_msi.c
line diff
     1.1 --- a/drivers/xen/pciback/conf_space_capability_msi.c	Fri Sep 05 12:39:29 2008 +0100
     1.2 +++ b/drivers/xen/pciback/conf_space_capability_msi.c	Sat Sep 06 14:14:42 2008 +0100
     1.3 @@ -2,6 +2,7 @@
     1.4   * PCI Backend -- Configuration overlay for MSI capability
     1.5   */
     1.6  #include <linux/pci.h>
     1.7 +#include <linux/slab.h>
     1.8  #include "conf_space.h"
     1.9  #include "conf_space_capability.h"
    1.10  #include <xen/interface/io/pciif.h>
    1.11 @@ -37,13 +38,16 @@ int pciback_disable_msi(struct pciback_d
    1.12  int pciback_enable_msix(struct pciback_device *pdev,
    1.13  		struct pci_dev *dev, struct xen_pci_op *op)
    1.14  {
    1.15 -	int i;
    1.16 -	int result;
    1.17 -	struct msix_entry entries[op->value];
    1.18 +	int i, result;
    1.19 +	struct msix_entry *entries;
    1.20  
    1.21  	if (op->value > SH_INFO_MAX_VEC)
    1.22  		return -EINVAL;
    1.23  
    1.24 +	entries = kmalloc(op->value * sizeof(*entries));
    1.25 +	if (entries == NULL)
    1.26 +		return -ENOMEM;
    1.27 +
    1.28  	for (i = 0; i < op->value; i++) {
    1.29  		entries[i].entry = op->msix_entries[i].entry;
    1.30  		entries[i].vector = op->msix_entries[i].vector;
    1.31 @@ -56,6 +60,8 @@ int pciback_enable_msix(struct pciback_d
    1.32  		op->msix_entries[i].vector = entries[i].vector;
    1.33  	}
    1.34  
    1.35 +	kfree(entries);
    1.36 +
    1.37  	op->value = result;
    1.38  
    1.39  	return result;