On 12.01.2022 16:15, Roger Pau Monné wrote:
> On Thu, Nov 25, 2021 at 01:02:44PM +0200, Oleksandr Andrushchenko wrote:
>> --- a/xen/drivers/vpci/header.c
>> +++ b/xen/drivers/vpci/header.c
>> @@ -137,45 +137,86 @@ bool vpci_process_pending(struct vcpu *v)
>>          return false;
>>  
>>      spin_lock(&pdev->vpci_lock);
>> -    if ( !pdev->vpci_cancel_pending && v->vpci.mem )
>> +    if ( !pdev->vpci )
>> +    {
>> +        spin_unlock(&pdev->vpci_lock);
>> +        return false;
>> +    }
>> +
>> +    if ( !pdev->vpci_cancel_pending && v->vpci.map_pending )
>>      {
>>          struct map_data data = {
>>              .d = v->domain,
>>              .map = v->vpci.cmd & PCI_COMMAND_MEMORY,
>>          };
>> -        int rc = rangeset_consume_ranges(v->vpci.mem, map_range, &data);
>> +        struct vpci_header *header = &pdev->vpci->header;
>> +        unsigned int i;
>>  
>> -        if ( rc == -ERESTART )
>> +        for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
>>          {
>> -            spin_unlock(&pdev->vpci_lock);
>> -            return true;
>> -        }
>> +            struct vpci_bar *bar = &header->bars[i];
>> +            int rc;
>> +
> 
> You should check bar->mem != NULL here, there's no need to allocate a
> rangeset for non-mappable BARs.

There's a NULL check ...

>> +            if ( rangeset_is_empty(bar->mem) )
>> +                continue;

... inside rangeset_is_empty() (to help callers like this one).

Jan


Reply via email to