mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-05 17:01:47 +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
|
void claim_interface(unsigned interface_num) override
|
||||||
{
|
{
|
||||||
|
if (!_device)
|
||||||
|
throw Device_not_found();
|
||||||
|
|
||||||
usb_interface *iface = _device->interface(interface_num);
|
usb_interface *iface = _device->interface(interface_num);
|
||||||
if (!iface)
|
if (!iface)
|
||||||
throw Interface_not_found();
|
throw Interface_not_found();
|
||||||
@ -653,6 +656,9 @@ class Usb::Session_component : public Session_rpc_object,
|
|||||||
|
|
||||||
void release_interface(unsigned interface_num) override
|
void release_interface(unsigned interface_num) override
|
||||||
{
|
{
|
||||||
|
if (!_device)
|
||||||
|
throw Device_not_found();
|
||||||
|
|
||||||
usb_interface *iface = _device->interface(interface_num);
|
usb_interface *iface = _device->interface(interface_num);
|
||||||
if (!iface)
|
if (!iface)
|
||||||
throw Interface_not_found();
|
throw Interface_not_found();
|
||||||
@ -663,6 +669,9 @@ class Usb::Session_component : public Session_rpc_object,
|
|||||||
void config_descriptor(Device_descriptor *device_descr,
|
void config_descriptor(Device_descriptor *device_descr,
|
||||||
Config_descriptor *config_descr) override
|
Config_descriptor *config_descr) override
|
||||||
{
|
{
|
||||||
|
if (!_device)
|
||||||
|
throw Device_not_found();
|
||||||
|
|
||||||
Genode::memcpy(device_descr, &_device->udev->descriptor, sizeof(usb_device_descriptor));
|
Genode::memcpy(device_descr, &_device->udev->descriptor, sizeof(usb_device_descriptor));
|
||||||
|
|
||||||
if (_device->udev->actconfig)
|
if (_device->udev->actconfig)
|
||||||
@ -677,6 +686,9 @@ class Usb::Session_component : public Session_rpc_object,
|
|||||||
|
|
||||||
unsigned alt_settings(unsigned index) override
|
unsigned alt_settings(unsigned index) override
|
||||||
{
|
{
|
||||||
|
if (!_device)
|
||||||
|
throw Device_not_found();
|
||||||
|
|
||||||
return _device->interface(index)->num_altsetting;
|
return _device->interface(index)->num_altsetting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user