device: prevent callbacks to device users that have been cleaned up already
authorFelix Fietkau <nbd@openwrt.org>
Mon, 16 Dec 2013 10:06:57 +0000 (11:06 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 16 Dec 2013 10:06:57 +0000 (11:06 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
device.c

index 56fc3f787713ce5eb0d9e3bf6833b460d1d264cd..feeb2902a371ac088058a7a7f49d1dd6bf95757f 100644 (file)
--- a/device.c
+++ b/device.c
@@ -185,6 +185,10 @@ static int device_broadcast_cb(void *ctx, struct safe_list *list)
        struct device_user *dep = container_of(list, struct device_user, list);
        int *ev = ctx;
 
+       /* device might have been removed by an earlier callback */
+       if (!dep->dev)
+               return 0;
+
        if (dep->cb)
                dep->cb(dep, *ev);
        return 0;