From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [91.216.245.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A9C817E9 for ; Fri, 15 Mar 2024 00:54:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.216.245.30 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710464045; cv=none; b=ETr/ik7qC9CN6FIoygSieVP4EIuQdUaCqGWn1WlAzkCy17rhSfwnckbVxffjxoBjS9t29YhBvMjbxslbtjrj/A25N1zGIjWIFCmvUESi1hnwglIp/bZCnabMGw0eHuKRiz1LmGDL/byEuI6bTnkikNX09dOEVVt7tUG/lwZwxHY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710464045; c=relaxed/simple; bh=+7fXd/kc8GVioLZNH5IaBf4XKLDzQvVjAKcuTWcfkqo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kXvbGLeByATFkLPwEoI2jGZSO+KTZ9LZVTdTCMGlD7LMbBkJxOnPyaCv4y46fDrncFopeUhIjAOKJkYGOw1XUgEpvi4vCX0zL7lDVtl3TX44aIBRa0eTA7h22IX4bVO3Ug/Xip8ibuOOruKfwV/t2nA4W/qAGRYN2v+A62F/sco= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strlen.de; spf=pass smtp.mailfrom=strlen.de; arc=none smtp.client-ip=91.216.245.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strlen.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=strlen.de Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1rkvpT-0002LQ-On; Fri, 15 Mar 2024 01:53:47 +0100 Date: Fri, 15 Mar 2024 01:53:47 +0100 From: Florian Westphal To: Chenyuan Yang Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, anjali.k.kulkarni@oracle.com, pctammela@mojatatu.com, andriy.shevchenko@linux.intel.com, dhowells@redhat.com, kuniyu@amazon.com, netdev@vger.kernel.org, zzjas98@gmail.com Subject: Re: [net/netlink] Question about potential memleak in netlink_proto_init() Message-ID: <20240315005347.GA8896@breakpoint.cc> References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Chenyuan Yang wrote: > Dear Netlink Developers, > > We are curious whether the function `netlink_proto_init()` might have a memory leak. Yes, but > The function is https://elixir.bootlin.com/linux/v6.8/source/net/netlink/af_netlink.c#L2908 > and the relevant code is > ``` > static int __init netlink_proto_init(void) > { > int i; > ... > > for (i = 0; i < MAX_LINKS; i++) { > if (rhashtable_init(&nl_table[i].hash, > &netlink_rhashtable_params) < 0) { > while (--i > 0) > rhashtable_destroy(&nl_table[i].hash); > kfree(nl_table); > goto panic; ... this calls panic(), kernel will crash intentionally. Perhaps best patch would be to remove this error handling and panic straight away, this is pretty much dead code.