Merge tag 'net-5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[linux-2.6-microblaze.git] / drivers / thunderbolt / icm.c
index 6255f1e..fff0c74 100644 (file)
@@ -1741,8 +1741,13 @@ static void icm_handle_event(struct tb *tb, enum tb_cfg_pkg_type type,
        if (!n)
                return;
 
-       INIT_WORK(&n->work, icm_handle_notification);
        n->pkg = kmemdup(buf, size, GFP_KERNEL);
+       if (!n->pkg) {
+               kfree(n);
+               return;
+       }
+
+       INIT_WORK(&n->work, icm_handle_notification);
        n->tb = tb;
 
        queue_work(tb->wq, &n->work);