On Tue, Feb 25, 2025 at 09:28:32AM +0100, Florian Westphal wrote:
Leon Romanovsky [off-list ref] wrote:
quoted
quoted
xfrm_hash_free() is kept around because of 'struct hlist_head *' arg type
instead of 'void *'.
<...>
quoted
-struct hlist_head *xfrm_hash_alloc(unsigned int sz);
-void xfrm_hash_free(struct hlist_head *n, unsigned int sz);
+static inline struct hlist_head *xfrm_hash_alloc(unsigned int sz)
+{
+ return kvzalloc(sz, GFP_KERNEL);
+}
+static inline void xfrm_hash_free(struct hlist_head *n)
+{
+ kvfree(n);
+}
Sorry, what does this wrapper give us?
You are passing pointer as is and there is no any pointer type check
that this construction will give us.
Compiler will warn when the argument is something other than a pointer
to a hlist_head.
I personally didn't see any bug where wrong pointer was passed to kfree :).
I can send a v2 with this wrapper removed if you don't think its worth it.
It is up to you.
Thanks for reviewing.