From nobody Mon Sep 15 19:11:14 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cQZPv4MqYz67snw; Mon, 15 Sep 2025 19:11:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cQZPt50wNz4FXC; Mon, 15 Sep 2025 19:11:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757963474; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+wEUYJn+AYT61BINbX2MbkEoDLUgdRbrwnWrIhXYli0=; b=pjPgOsgRjehfChWt2+39XDU7mS873q+q/wummQUxED2F03UN/30hzs7s579SdQLaWxA8cT yjHpcKaIPQEUf3sAi1FeC3tm0+2yIMUA6fIHwtXVahu4YCdq7/uxspnmuKQFAjyVOcrNSl QUH11Rg23FuQwkYDCrQraEgHZneIJnuhXX5FIb7uto7X8pIaZIfESzGiI1CsEl3RwL3wZ4 RbblpYWUsPXK1hSsmQM5AL6gNJwsZubt3LAGROEG45fAcltFrfEF8/l5h1SGq+BF+rALKP NbI7iGzVSfn9wiYWXXI/yvtzCTU+sSvtJ0cL4FTSf5Afkvgrt8CavK1cDFr8iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757963474; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+wEUYJn+AYT61BINbX2MbkEoDLUgdRbrwnWrIhXYli0=; b=Gp4DlkWe/KzTfM6hjStch98Zi7k1uu4ZSseden/N2prbMnx7NK29rL5a1E+Um1qjQTB2Z/ 5HYGhJ6UpxPIYEfn0hKc/HkWPPW9BLfIQQ78+ax3SuqCBcY5/Hx8d5nMFQ/AXV0nSELwSd ExVI+qsnmCKCFUTxZl5qMCrUUPLVUuIe8hKtBZV4L7BWZSuw+DQt0lpmlcNudFsPLOdyHQ q+o25tOHXoOeSAwLBEOMytiR+EsCwxXAvlVlXhdQunO9hM1GTLhPITOesFTsNIue3aKlZJ wfZ5yxF/LcT3hbHkApdZQhrJ9CZA0hqjbo3gTzUbkuQCY/dSh051zKnADTDIig== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1757963474; a=rsa-sha256; cv=none; b=k9sdgmIkQGqqjg1nE7h+22NZ7aA9DXSrhBxMJm3Fu3ISXDy7MxoY1fbE7o/jCCn0GRir1n X1tH9QgB1SNibfe9mzBBE1UFYOyTkAzWwlw/XAxcZD2CJq2BGRjw+FYq86hPqRgf7l9lmx 7HIcQT3j5e1M3dzArinfo0P8XnIWBoJZ+rcuknffLY2vSqN5r465tth8Or4VnCnikmuV2/ kB7Oxo9EwLeWw0umLe6SWN0Q7rYLcZptM0hXSrDLV/l8S7t+IRReKf8zkktgAtQwgIcAuR Aa5USTO8akWLPU/pQ0cXByCi4BMA1n4qTslxrRqTf6qp5qUAj+Srh8Q0uOX41A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cQZPt4XC0z16By; Mon, 15 Sep 2025 19:11:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 58FJBEJV049887; Mon, 15 Sep 2025 19:11:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58FJBE2m049884; Mon, 15 Sep 2025 19:11:14 GMT (envelope-from git) Date: Mon, 15 Sep 2025 19:11:14 GMT Message-Id: <202509151911.58FJBE2m049884@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 830cc677d97e - stable/15 - LinuxKPI: cleanup: implement __free() and DEFINE_FREE(); use for kfree() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 830cc677d97eebd02ade8b33ec17de38f2705a73 Auto-Submitted: auto-generated The branch stable/15 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=830cc677d97eebd02ade8b33ec17de38f2705a73 commit 830cc677d97eebd02ade8b33ec17de38f2705a73 Author: Bjoern A. Zeeb AuthorDate: 2025-09-04 20:24:55 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-09-15 14:52:25 +0000 LinuxKPI: cleanup: implement __free() and DEFINE_FREE(); use for kfree() A wifi driver update needs this. Sponsored by: The FreeBSD Foundation (initially) Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D52075 (cherry picked from commit 39e9290d890b2aa07b68f2fe956b96e5df9a1da2) --- sys/compat/linuxkpi/common/include/linux/cleanup.h | 14 +++++++++++++- sys/compat/linuxkpi/common/include/linux/slab.h | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/include/linux/cleanup.h b/sys/compat/linuxkpi/common/include/linux/cleanup.h index 01f234f0cbe7..45c2a2359ddf 100644 --- a/sys/compat/linuxkpi/common/include/linux/cleanup.h +++ b/sys/compat/linuxkpi/common/include/linux/cleanup.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2024 The FreeBSD Foundation + * Copyright (c) 2024-2025 The FreeBSD Foundation * * This software was developed by Björn Zeeb under sponsorship from * the FreeBSD Foundation. @@ -43,4 +43,16 @@ guard_ ## _n ## _t guard_ ## _n ## _ ## __COUNTER__ \ __cleanup(guard_ ## _n ## _destroy) = guard_ ## _n ## _create +#define DEFINE_FREE(_n, _t, _f) \ + static inline void \ + __free_ ## _n(void *p) \ + { \ + _t _T; \ + \ + _T = *(_t *)p; \ + _f; \ + } + +#define __free(_n) __cleanup(__free_##_n) + #endif /* _LINUXKPI_LINUX_CLEANUP_H */ diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h b/sys/compat/linuxkpi/common/include/linux/slab.h index 47e3d133eb6c..0e649e1e3c4a 100644 --- a/sys/compat/linuxkpi/common/include/linux/slab.h +++ b/sys/compat/linuxkpi/common/include/linux/slab.h @@ -40,8 +40,10 @@ #include #include #include +#include #include #include +#include MALLOC_DECLARE(M_KMALLOC); @@ -153,6 +155,8 @@ kfree(const void *ptr) lkpi_kfree(ptr); } +DEFINE_FREE(kfree, void *, if (!IS_ERR_OR_NULL(_T)) kfree(_T)) + /* * Other k*alloc() funtions using the above as underlying allocator. */