Re: [PATCH] pci: Parenthesize parameters in PCI_DEVID and PCI_VPD_LRDT_ID macros

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

 



On Fri, Sep 05, 2014 at 08:19:10PM -0700, Jeff Kirsher wrote:
> From: Megan Kamiya <megan.a.kamiya@xxxxxxxxx>
> 
> Add parentheses around parameters in PCI_DEVID and PCI_VPD_LRDT_ID
> macros to prevent possible expansion errors as described by the CERT
> Secure Coding Standard: PRE01-C: Use parentheses within macros around
> parameter names
> 
> Signed-off-by: Megan Kamiya <megan.a.kamiya@xxxxxxxxx>
> Tested-by: Aaron Brown <aaron.f.brown@xxxxxxxxx>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@xxxxxxxxx>

Applied to pci/misc for v3.18, thanks!

> ---
>  include/linux/pci.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 61978a4..cb744f3 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -45,7 +45,7 @@
>   * In the interest of not exposing interfaces to user-space unnecessarily,
>   * the following kernel-only defines are being added here.
>   */
> -#define PCI_DEVID(bus, devfn)  ((((u16)bus) << 8) | devfn)
> +#define PCI_DEVID(bus, devfn)  ((((u16)(bus)) << 8) | (devfn))
>  /* return bus from PCI devid = ((u16)bus_number) << 8) | devfn */
>  #define PCI_BUS_NUM(x) (((x) >> 8) & 0xff)
>  
> @@ -1701,7 +1701,7 @@ bool pci_acs_path_enabled(struct pci_dev *start,
>  			  struct pci_dev *end, u16 acs_flags);
>  
>  #define PCI_VPD_LRDT			0x80	/* Large Resource Data Type */
> -#define PCI_VPD_LRDT_ID(x)		(x | PCI_VPD_LRDT)
> +#define PCI_VPD_LRDT_ID(x)		((x) | PCI_VPD_LRDT)
>  
>  /* Large Resource Data Type Tag Item Names */
>  #define PCI_VPD_LTIN_ID_STRING		0x02	/* Identifier String */
> -- 
> 1.9.3
> 
--
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