wireless: fix use-after-free bug
[project/netifd.git] / bridge.c
index 0e06cc2..4ef0d7e 100644 (file)
--- a/bridge.c
+++ b/bridge.c
@@ -318,6 +318,9 @@ bridge_create_member(struct bridge_state *bst, struct device *dev, bool hotplug)
        struct bridge_member *bm;
 
        bm = calloc(1, sizeof(*bm) + strlen(dev->ifname) + 1);
        struct bridge_member *bm;
 
        bm = calloc(1, sizeof(*bm) + strlen(dev->ifname) + 1);
+       if (!bm)
+               return NULL;
+
        bm->bst = bst;
        bm->dev.cb = bridge_member_cb;
        bm->dev.hotplug = hotplug;
        bm->bst = bst;
        bm->dev.cb = bridge_member_cb;
        bm->dev.hotplug = hotplug;