From nobody Fri Sep 5 23:29:04 2025 X-Original-To: dev-commits-src-main@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 4cJXc10FKxz66Ydf; Fri, 05 Sep 2025 23:29:05 +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 4cJXc05Fvzz40sB; Fri, 05 Sep 2025 23:29:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757114944; 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=XnENN7ZySUpyQSf9c/JZtjVrt/KzpInjezxErih3Pf0=; b=tDm3BAMXf0zo8syZzEExgtOTxXS0VK3WNDSSqf+l+2U54jiWZPSiNM/0iYuL9d7g1mUMmm 7L4GxXQDZaCdYRbcBaYYsKm9pmoBbY8QvihWXm1Azev0nVVlj4XSwF850hjeqb+BleaMzc xHWOsDWI3TYPg0U3KR0jxa4jVJKMUiZ213FTrjLOJaNyYpD3xGUvyPauf56L09RYAICPwB aJXFHHeKIazIhlWRjMPU02roFQUsUVEJ/QHk8MU1STZPBwOLGkM0tau5R3iby16BXe35id yLvz/zkYIJidlDM2qOBA2kgyxhfx7x6hFUVjkpBsam6jT97roINCvwOOD0mE9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757114944; 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=XnENN7ZySUpyQSf9c/JZtjVrt/KzpInjezxErih3Pf0=; b=CogCmJj/t1W5NneVVTcfURjo4+fIWh3+oNxdFklAH4Q8Q0FfBXAbaDyuwafm4YfqcV3p0C n1fjainKJ2wYSnY+EqdSRzzXWxNZlXSNxZ7C4OzclLKvJfTN4f5UR861dF8tvdHeCCm5eH 2rhhc+jcIa6OuL2VRm6K7NH3BJ5B5i9x4EwhlW4e0DBkCMCYQOuQGfbZTIFZeSgvh5CBix gGrIPXoXkUhK082kYm00R3M4y47uxymXXNX4h1/tlCC2WPRGWx6xzsHKQwP5cNLu4bhv3G UfNuFbEBZ8JfKL3yCTejQvux6kdv9ZchYsLWw2eje5woSl9R+TuPw1F5vvoSlQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1757114944; a=rsa-sha256; cv=none; b=reUOeuqbGUXUKz92IF05pfJryJe5NyBFaq+60x9p7+MhcHpKpxdcHy4y1mxEXusYCai4M9 7/iMs0aKQ7vTYBLXWlJUPoXce0T+lcknUvOAp0LLXaDwd1s/z3ScM68TOIyEnA/yEyn0k1 TncdYlA4LwZRhwLfjR5H9UeioWylNrsYJMavn63UEP08HwzBRbacPZFZRSoGVzNTljcImy uE9Wn8K40Od59meOHprDmGEai1yNneE1G+8Ar8zr9Ql4Ww47tGK60xkpDZC03APe3wLLwU 7ofcA22c1GQNNo7cNYtfDJnEpebzl2ZeXqHDHilLEJCWS8fg1U0KVY25JMmhoQ== 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 4cJXc04sR4z17q8; Fri, 05 Sep 2025 23:29:04 +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 585NT4ZR029368; Fri, 5 Sep 2025 23:29:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 585NT42u029365; Fri, 5 Sep 2025 23:29:04 GMT (envelope-from git) Date: Fri, 5 Sep 2025 23:29:04 GMT Message-Id: <202509052329.585NT42u029365@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 39e9290d890b - main - LinuxKPI: cleanup: implement __free() and DEFINE_FREE(); use for kfree() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 39e9290d890b2aa07b68f2fe956b96e5df9a1da2 Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=39e9290d890b2aa07b68f2fe956b96e5df9a1da2 commit 39e9290d890b2aa07b68f2fe956b96e5df9a1da2 Author: Bjoern A. Zeeb AuthorDate: 2025-09-04 20:24:55 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-09-05 23:24:15 +0000 LinuxKPI: cleanup: implement __free() and DEFINE_FREE(); use for kfree() A wifi driver update needs this. Sponsored by: The FreeBSD Foundation (initially) MFC after: 3 days Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D52075 --- 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. */