Re: [PATCH] PCI/MSI: pci_irq_get_affinity() should cope with NULL affinity vector

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

 



On Tue, Nov 08, 2016 at 12:43:54AM -0700, Jan Beulich wrote:
> msi_setup_entry() only logs a message when the affinity vector can't be
> allocated, and hence pci_irq_get_affinity() indexing entry->affinity is
> wrong without a prior check.
> 
> Fixes: ee8d41e53efe "pci/msi: Retrieve affinity for a vector"
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: Christoph Hellwig <hch@xxxxxx>

Applied to pci/msi for v4.10 with Christoph's reviewed-by and the following
changelog:

  PCI/MSI: Check for NULL affinity mask in pci_irq_get_affinity()
  
  If msi_setup_entry() fails to allocate an affinity mask, it logs a message
  but continues on and allocates an MSI entry with entry->affinity == NULL.
  
  Check for this case in pci_irq_get_affinity() so we don't try to
  dereference a NULL pointer.

> ---
>  drivers/pci/msi.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> --- 4.9-rc4/drivers/pci/msi.c
> +++ 4.9-rc4-PCI-MSI-no-affinity/drivers/pci/msi.c
> @@ -1294,7 +1294,8 @@ const struct cpumask *pci_irq_get_affini
>  	} else if (dev->msi_enabled) {
>  		struct msi_desc *entry = first_pci_msi_entry(dev);
>  
> -		if (WARN_ON_ONCE(!entry || nr >= entry->nvec_used))
> +		if (WARN_ON_ONCE(!entry || !entry->affinity ||
> +				 nr >= entry->nvec_used))
>  			return NULL;
>  
>  		return &entry->affinity[nr];
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux