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

[tyndur-devel] [PATCH 2/3] usb1: Fix für Race bei der Behandlung von Geräten ohne Treiber



! usb1: Während die Liste aller Geräte ohne Treiber durchsucht/verändert
  wird, dürfen keine RPCs dazwischenfunken, sonst kommen unsinnige
  Listengrößen raus und wir bekommen NULL-Pointer zurück.

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 src/modules/usb/usb1/detect.c |    2 ++
 src/modules/usb/usb1/rpc.c    |    2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/modules/usb/usb1/detect.c b/src/modules/usb/usb1/detect.c
index 54ed6d7..426933b 100644
--- a/src/modules/usb/usb1/detect.c
+++ b/src/modules/usb/usb1/detect.c
@@ -101,7 +101,9 @@ static void dev_is_unhandled(struct usb_device* dev, int ifc_num,
     pd->type.subclass = (ifc == NULL) ? dev->dev_desc->subclass : ifc->subclass;
     pd->type.protocol = (ifc == NULL) ? dev->dev_desc->protocol : ifc->protocol;
 
+    p();
     list_push(unhandled_devs, pd);
+    v();
 }
 
 #define check(svar, lname) int svar##f = fits(svar, drv->handle.lname); \
diff --git a/src/modules/usb/usb1/rpc.c b/src/modules/usb/usb1/rpc.c
index 17d192e..51bf0ca 100644
--- a/src/modules/usb/usb1/rpc.c
+++ b/src/modules/usb/usb1/rpc.c
@@ -85,6 +85,7 @@ static void ddrv_handler(pid_t src, uint32_t corr_id, size_t length, void* data)
         return;
     }
 
+    p();
     struct usb_ddrv* drv = calloc(1, sizeof(*drv));
     drv->pid = src;
     drv->handle = *hd;
@@ -105,6 +106,7 @@ static void ddrv_handler(pid_t src, uint32_t corr_id, size_t length, void* data)
             s--;
         }
     }
+    v();
 
     rpc_send_int_response(src, corr_id, 42);
 }
-- 
1.6.0.2