lkml.org 
[lkml]   [2018]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 1/1] x86/platform/x86: Fix count of CHas on multi-pci-segment arches
On Tue, Mar 13, 2018 at 3:42 AM, Liang, Kan <kan.liang@linux.intel.com> wrote:

> +#define SKX_CAPID6 0x9c
> +#define SKX_CHA_BIT_WIDTH 28
> +
> static int skx_count_chabox(void)
> {
> + struct pci_dev *dev = NULL;
> + u32 val = 0;
>

> + dev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x2083, dev);
> + if (!dev)
> + return 0;

Where is pci_dev_put()?

>
> + pci_read_config_dword(dev, SKX_CAPID6, &val);
> + return bitmap_weight((unsigned long *)&val, SKX_CHA_BIT_WIDTH);

UB is here.
Fix is simple, use unsigned long and drop this ugly casting.

> }

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2018-03-13 16:59    [W:1.460 / U:0.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site