net: sock: remove the unnecessary check in proto_register
authorTonghao Zhang <xiangxia.m.yue@gmail.com>
Thu, 22 Apr 2021 13:41:51 +0000 (21:41 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 23 Apr 2021 20:10:03 +0000 (13:10 -0700)
tw_prot_cleanup will check the twsk_prot.

Fixes: 0f5907af3913 ("net: Fix potential memory leak in proto_register()")
Cc: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/sock.c

index 5ec90f99e102895417adb6422c00a6943fd09182..c761c4a0b66b1d34ed1671727daf86738bff6c92 100644 (file)
@@ -3531,7 +3531,7 @@ int proto_register(struct proto *prot, int alloc_slab)
        return ret;
 
 out_free_timewait_sock_slab:
-       if (alloc_slab && prot->twsk_prot)
+       if (alloc_slab)
                tw_prot_cleanup(prot->twsk_prot);
 out_free_request_sock_slab:
        if (alloc_slab) {