Re: [PATCH 9/9] PCI: dwc: Add pcie port pointer validation

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

 



[+Marc, for his information]

On Wed, Jan 16, 2019 at 11:14:22AM +0100, Gustavo Pimentel wrote:
> Add pcie port pointer validation to avoid a potencial crash accessing a
> null pointer reported by coverity scan.

s/potencial/potential
s/null/NULL

> Warning generated by coverity: "Dereferencing a pointer that might be
> null "data" when calling "irq_data_get_irq_chip_data".

s/null/NULL

> Signed-off-by: Gustavo Pimentel <gustavo.pimentel@xxxxxxxxxxxx>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@xxxxxxx>
> Cc: Joao Pinto <jpinto@xxxxxxxxxxxx>
> Cc: Jingoo Han <jingoohan1@xxxxxxxxx>
> ---
>  drivers/pci/controller/dwc/pcie-designware-host.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
> index 45ff5e4..419a56b 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-host.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c
> @@ -256,9 +256,14 @@ static void dw_pcie_irq_domain_free(struct irq_domain *domain,
>  				    unsigned int virq, unsigned int nr_irqs)
>  {
>  	struct irq_data *d = irq_domain_get_irq_data(domain, virq);
> -	struct pcie_port *pp = irq_data_get_irq_chip_data(d);
> +	struct pcie_port *pp;
>  	unsigned long flags;
>  
> +	if (!d)
> +		return;
> +
> +	pp = irq_data_get_irq_chip_data(d);

Well, we do not validate pp either and I wonder whether coverity trips
over this code path but that's just a false positive.

If we have to actually patch it there are other code paths in the kernel
to be updated too.

Lorenzo

> +
>  	raw_spin_lock_irqsave(&pp->lock, flags);
>  
>  	bitmap_release_region(pp->msi_irq_in_use, d->hwirq,
> -- 
> 2.7.4
> 



[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