Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E4F5C61DA4 for ; Sat, 11 Mar 2023 03:15:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbjCKDPG (ORCPT ); Fri, 10 Mar 2023 22:15:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbjCKDO7 (ORCPT ); Fri, 10 Mar 2023 22:14:59 -0500 Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10EEF133A4C for ; Fri, 10 Mar 2023 19:14:57 -0800 (PST) From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1678504495; bh=sOiskQrdfCnIJT4uxkWaPY9RlNau8EXPiu1P/We8tr0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=r/d9r6prZI3rN88Jp8LpvVV4Mclk1h/7E1U1QKzH2As+OnhYe1m3BJ3lpvCqdoDRR 73Yyu6R8b0J3Vpa3t6yAjxvuHDG7lGPTT+KqdxAV8ZMFB1WhF6f9jVPMe/4aN48OqQ oXGNywQObYH9ARQEdw7bFa/nYQjggFazBV3pqFBo= Date: Sat, 11 Mar 2023 03:14:49 +0000 Subject: [PATCH 4/4] kobject: upgrade log of missing release func to warn MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20230311-kobject-warning-v1-4-1ebba4f71fb5@weissschuh.net> References: <20230311-kobject-warning-v1-0-1ebba4f71fb5@weissschuh.net> In-Reply-To: <20230311-kobject-warning-v1-0-1ebba4f71fb5@weissschuh.net> To: Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1678504493; l=1778; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=sOiskQrdfCnIJT4uxkWaPY9RlNau8EXPiu1P/We8tr0=; b=1ar91zJaVsxFyRXTGIyF83f5ARIzmhFC06gDZVTbz4t54KvrLwhjwOawF3WfOLvvQEPg1PIEi 02YIqkm5pAjC3TH5+EyWKZjVzcYuLfMLDj8RjMEHNFi76kqhIebznaV X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The documentation is outspoken in its requirement for a release() function. Documentation/core-api/kobject.rst: One important point cannot be overstated: every kobject must have a release() method, and the kobject must persist (in a consistent state) until that method is called. If these constraints are not met, the code is flawed. Note that the kernel will warn you if you forget to provide a release() method. Do not try to get rid of this warning by providing an "empty" release function. So adapt the logging to actually provide the promised warning. At the moment there are still kobjects that do not have a release() function, notably integrity_ktype and acpi_hotplug_profile_ktype. Therefore leave it at pr_warn(). When the remaining cases are fixed the message could be upgraded to pr_err() and/or an -EINVAL could be returned. Signed-off-by: Thomas Weißschuh --- lib/kobject.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/kobject.c b/lib/kobject.c index 68ff8a48b784..8723f477095e 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -215,9 +215,11 @@ static int kobject_add_internal(struct kobject *kobj) return -EINVAL; } - if (kobj->ktype && !kobj->ktype->release) - pr_debug("'%s' (%p): does not have a release() function, it is broken and must be fixed. See Documentation/core-api/kobject.rst.\n", - kobject_name(kobj), kobj); + if (kobj->ktype && !kobj->ktype->release) { + pr_warn("'%s' (%p): does not have a release() function, it is broken and must be fixed. See Documentation/core-api/kobject.rst.\n", + kobject_name(kobj), kobj); + dump_stack_lvl(KERN_WARNING); + } parent = kobject_get(kobj->parent); -- 2.39.2