mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-24 07:46:42 +00:00
usb_drv: add missing device pointer checks
The usb_drv must always check the device pointer in all session facing. methods. A errorneous client can otherwise trigger a page-fault in the driver. Fixes #2133.
This commit is contained in:
parent
82e228a715
commit
dee56aeafa
@ -643,6 +643,9 @@ class Usb::Session_component : public Session_rpc_object,
|
||||
|
||||
void claim_interface(unsigned interface_num) override
|
||||
{
|
||||
if (!_device)
|
||||
throw Device_not_found();
|
||||
|
||||
usb_interface *iface = _device->interface(interface_num);
|
||||
if (!iface)
|
||||
throw Interface_not_found();
|
||||
@ -653,6 +656,9 @@ class Usb::Session_component : public Session_rpc_object,
|
||||
|
||||
void release_interface(unsigned interface_num) override
|
||||
{
|
||||
if (!_device)
|
||||
throw Device_not_found();
|
||||
|
||||
usb_interface *iface = _device->interface(interface_num);
|
||||
if (!iface)
|
||||
throw Interface_not_found();
|
||||
@ -663,6 +669,9 @@ class Usb::Session_component : public Session_rpc_object,
|
||||
void config_descriptor(Device_descriptor *device_descr,
|
||||
Config_descriptor *config_descr) override
|
||||
{
|
||||
if (!_device)
|
||||
throw Device_not_found();
|
||||
|
||||
Genode::memcpy(device_descr, &_device->udev->descriptor, sizeof(usb_device_descriptor));
|
||||
|
||||
if (_device->udev->actconfig)
|
||||
@ -677,6 +686,9 @@ class Usb::Session_component : public Session_rpc_object,
|
||||
|
||||
unsigned alt_settings(unsigned index) override
|
||||
{
|
||||
if (!_device)
|
||||
throw Device_not_found();
|
||||
|
||||
return _device->interface(index)->num_altsetting;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user