Re: [PATCH v3 3/6] usb: usbip tool: Check the return of get_nports()

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

 



On 04/10/2017 04:38 PM, Yuyang Du wrote:
> Hi Shuah,
> 
> Could you please take a look at these patches? I got more patches
> that sit on these to send out.

Please bear with me. I was out sick most of last week. Still catching
up. Go ahead and send the patches, no need to wait.

> 
> Thanks,
> Yuyang
> 
> On Thu, Apr 06, 2017 at 06:03:24AM +0800, Yuyang Du wrote:
>> If we get nonpositive number of ports, there is no sense to
>> continue, then fail gracefully.
>>
>> In addition, the commit 0775a9cbc694e8c72 ("usbip: vhci extension:
>> modifications to vhci driver") introduced configurable numbers of
>> controllers and ports, but we have a static port number maximum,
>> MAXNPORT. If exceeded, the idev array will be overflown. We fix
>> it by validating the nports to make sure the port number max is
>> not exceeded.
>>
>> Signed-off-by: Yuyang Du <yuyang.du@xxxxxxxxx>

Greg,

Could you please pick this up.

Acked-by: Shuah Khan <shuahkh@xxxxxxxxxxxxxxx>

thanks,
-- Shuah

>> ---
>>  tools/usb/usbip/libsrc/vhci_driver.c | 10 +++++++++-
>>  1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/usb/usbip/libsrc/vhci_driver.c b/tools/usb/usbip/libsrc/vhci_driver.c
>> index f659c14..151580a 100644
>> --- a/tools/usb/usbip/libsrc/vhci_driver.c
>> +++ b/tools/usb/usbip/libsrc/vhci_driver.c
>> @@ -220,9 +220,17 @@ int usbip_vhci_driver_open(void)
>>  	}
>>  
>>  	vhci_driver->nports = get_nports();
>> -
>>  	dbg("available ports: %d", vhci_driver->nports);
>>  
>> +	if (vhci_driver->nports <=0) {
>> +		err("no available ports");
>> +		goto err;
>> +	}
>> +	else if (vhci_driver->nports > MAXNPORT) {
>> +		err("port number exceeds %d", MAXNPORT);
>> +		goto err;
>> +	}
>> +
>>  	if (refresh_imported_device_list())
>>  		goto err;
>>  
>> -- 
>> 2.7.4
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux