RE: [PATCH] megaraid_sas: Fix the search of first memory bar

From: Sumit Saxena
Date: Fri Aug 26 2016 - 00:54:49 EST


>-----Original Message-----
>From: Christophe JAILLET [mailto:christophe.jaillet@xxxxxxxxxx]
>Sent: Sunday, August 21, 2016 1:58 PM
>To: kashyap.desai@xxxxxxxxxxxxx; sumit.saxena@xxxxxxxxxxxxx;
>uday.lingala@xxxxxxxxxxxxx; jejb@xxxxxxxxxxxxxxxxxx;
>martin.petersen@xxxxxxxxxx
>Cc: megaraidlinux.pdl@xxxxxxxxxxxxx; linux-scsi@xxxxxxxxxxxxxxx; linux-
>kernel@xxxxxxxxxxxxxxx; kernel-janitors@xxxxxxxxxxxxxxx; Christophe JAILLET
>Subject: [PATCH] megaraid_sas: Fix the search of first memory bar
>
>The 2nd parameter of 'find_first_bit' is the number of bits to search.
>In this case, we are passing 'sizeof(unsigned long)' which is likely to be
>4.
>
>It is likely that the number of bits in a long was expected here, so use
>BITS_PER_LONG instead.
>
>Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
>---
>Other options are possible:
> - 'bar_list' being a 'unsigned long', use __ffs to reduce code verbosity
> - PCI_NUM_RESOURCES, which is the maximum number of bits that can be set
> by 'pci_select_bars()'
>---
> drivers/scsi/megaraid/megaraid_sas_base.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c
>b/drivers/scsi/megaraid/megaraid_sas_base.c
>index c1ed25adb17e..7d3de811d33c 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_base.c
>+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
>@@ -5036,7 +5036,7 @@ static int megasas_init_fw(struct megasas_instance
>*instance)
>
> /* Find first memory bar */
> bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM);
>- instance->bar = find_first_bit(&bar_list, sizeof(unsigned long));
>+ instance->bar = find_first_bit(&bar_list, BITS_PER_LONG);
> if (pci_request_selected_regions(instance->pdev, 1<<instance->bar,
> "megasas: LSI")) {
> dev_printk(KERN_DEBUG, &instance->pdev->dev, "IO memory
>region busy!\n");

Acked by: Sumit Saxena <sumit.saxena@xxxxxxxxxxxx>

>--
>2.7.4
>
>
>---
>L'absence de virus dans ce courrier Ãlectronique a Ãtà vÃrifiÃe par le
>logiciel
>antivirus Avast.
>https://www.avast.com/antivirus