From patchwork Thu Feb 8 16:02:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 198456 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp269107dyd; Thu, 8 Feb 2024 08:03:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWng2x0xQaDIu2MBuA+bJzv7J/MMojFwovQrVpm3IhcioS5rG86sn9PmrJwYXpdCbr8DJlZxnZBbKjzCx+hATqsQvuyaQ== X-Google-Smtp-Source: AGHT+IFqMUaM7t2HJfLDThDbnWl7C7kJwXxiZWnSHzhjq7l4EPPj+EjFF3dT8reEsN4nTZbuIotb X-Received: by 2002:a05:6871:b23:b0:219:55ca:67f7 with SMTP id fq35-20020a0568710b2300b0021955ca67f7mr10893227oab.21.1707408191871; Thu, 08 Feb 2024 08:03:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707408191; cv=pass; d=google.com; s=arc-20160816; b=SmzCSqZeEXdhT/tZJ6Glvnk8NyRD36N9yM7WeJTLqglxYmU9f3KPP9zMX/hAP8+ih9 3PsOz7+a8ZhznBdY3oGkS25kdLTCglNYCMcLn/ZjrvbviGzdIAcYSR0T+iP/bv70+Q0z 6x/9UYMlqn8Vm6jNkdgxAgwOQiYjP0y9nk44V/tL7GcbotgsuYAJllZyPpFjZFNgq40E 6Pwm+OPWPAPT3XmtGFKqraK6vjThWVyCGijH5y/RvWiusxQAF3RC/ztzkXAL6eClur6p CUip8l1qfIQU8XOqoccmHROEBuH++C1joCFVfrgD2rkidgiXjOKcCnOiFdXBir2sSBI3 XEZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:lines:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=U9cffSiVPqeXgevhBlA99vmi3DYtHQzCsxTcgzmryhM=; fh=QY6ugFyqtyoQAK3SKuVRGdqSJ0HmXc3FFub1yYJMh1s=; b=q9t0d19shOF1h35j8izeInfcYn+wUdpZZvxiCXF1Lt9YNz+tWy3Gv6lFVZ9kkFEIch PfhObb/+0gAVkFyC77V7ohTh64N133weBXPqlB6hXTnW0cYikwroEYQ/hKz7Z4OdMY6e 37i0nOnYac/Wo3xuLLIsYLivaQFIt7sRnxnAvX/5gkpi0fT4p7LhAfUaaUMeFSSOdJ1P f1YXYYSe04T2M72AQT9GriGcrWb6WSoNV3mMbcQNEZFE4AcLco+2T8O1zBGjsVY67Q5k p19yTvo0hd6E/8DSuNyRpKedRLLoTRw9QUqodxvRZMcY4o03dVCOlSMFuHQEvDzDEDJG 5Kug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BcIzvkQj; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-58320-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58320-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org X-Forwarded-Encrypted: i=2; AJvYcCVCZZtanzUAot8NrM3ukkblDh216UOpmEDKxrwzMTqZ0WDyaQFGX/ixEaDKnrH5KEGSuqYi98njZAhmgbLiiRV7humPVw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a14-20020a056830008e00b006e0cb7abd1dsi1624317oto.205.2024.02.08.08.03.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 08:03:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58320-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BcIzvkQj; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-58320-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58320-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3D8172856BD for ; Thu, 8 Feb 2024 16:03:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 34E4C7E565; Thu, 8 Feb 2024 16:02:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="BcIzvkQj" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 71A6F7C6EF for ; Thu, 8 Feb 2024 16:02:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707408176; cv=none; b=WBKx5ZJtnurhhjrkCMbKR3ugz62HYodCsyUsboH7TOmodEpbFnCRuqWd4P2+QPul3Y2oNiGLNdB0V+UwPSm8y7X1evrYkl6Tw/oqCfsAWDiQAUDZOVL0POb9rce3PLLAhUncEP9U7LSH/tvW5BDw14ElKp5prU5gQXWHR9zL8ZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707408176; c=relaxed/simple; bh=xp928LhpMo0dQmyBfHTiAL78Ljncr+lZjAsOE2TSsW0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=lVQ4M4KE/Fo1T4dFKC4UXoPp1NXHi4s+BdB1YsA+89Rxag/MmmPuLqvySKgTejSCmDS27G3BnOh5bI3nqQpwLaQDOWAZeL9izOnfZsWTI+MW1ar7zxyJFUsdSx26UPZe2PlT5wMtzqR9Ua8+5+8A+1eGRLs1o8zQvvz6U6hH5Uw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=BcIzvkQj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A82B2C433F1; Thu, 8 Feb 2024 16:02:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1707408176; bh=xp928LhpMo0dQmyBfHTiAL78Ljncr+lZjAsOE2TSsW0=; h=From:To:Cc:Subject:Date:From; b=BcIzvkQjcy6N4+lJzoFQ07C7gT6AqkgllAvTF7bGwkye65nxgeer9rHYYNi3TdP9B NORZYeBGh1oG/uz12wNf620tFD3R1cC/P1/ysWDKsK86CFc4KCz+JgK/6NkIlSa/rF rHAYNgwxikyIGdRermbUmz/2WmUjEWmsN09h5Xq0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , kernel test robot , Zhen Lei Subject: [PATCH] Revert "kobject: Remove redundant checks for whether ktype is NULL" Date: Thu, 8 Feb 2024 16:02:50 +0000 Message-ID: <2024020849-consensus-length-6264@gregkh> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Lines: 82 X-Developer-Signature: v=1; a=openpgp-sha256; l=2835; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=xp928LhpMo0dQmyBfHTiAL78Ljncr+lZjAsOE2TSsW0=; b=owGbwMvMwCRo6H6F97bub03G02pJDKlHfms9aSz+v3u7na27m3dej/iSVR9Lpqft6b4fsZ/x1 optrj83dcSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEXsQwzBXy2r7fO/hXr9q/ 9JVpZ+v2JC6ff4Rhnu6k2X76u7OeCRZlLgqziXiQybDzKAA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790347252120131967 X-GMAIL-MSGID: 1790347252120131967 This reverts commit 1b28cb81dab7c1eedc6034206f4e8d644046ad31. It is reported to cause problems, so revert it for now until the root cause can be found. Reported-by: kernel test robot Fixes: 1b28cb81dab7 ("kobject: Remove redundant checks for whether ktype is NULL") Cc: Zhen Lei Closes: https://lore.kernel.org/oe-lkp/202402071403.e302e33a-oliver.sang@intel.com Signed-off-by: Greg Kroah-Hartman --- lib/kobject.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/kobject.c b/lib/kobject.c index 59dbcbdb1c91..72fa20f405f1 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -74,10 +74,12 @@ static int create_dir(struct kobject *kobj) if (error) return error; - error = sysfs_create_groups(kobj, ktype->default_groups); - if (error) { - sysfs_remove_dir(kobj); - return error; + if (ktype) { + error = sysfs_create_groups(kobj, ktype->default_groups); + if (error) { + sysfs_remove_dir(kobj); + return error; + } } /* @@ -589,7 +591,8 @@ static void __kobject_del(struct kobject *kobj) sd = kobj->sd; ktype = get_ktype(kobj); - sysfs_remove_groups(kobj, ktype->default_groups); + if (ktype) + sysfs_remove_groups(kobj, ktype->default_groups); /* send "remove" if the caller did not do it but sent "add" */ if (kobj->state_add_uevent_sent && !kobj->state_remove_uevent_sent) { @@ -666,6 +669,10 @@ static void kobject_cleanup(struct kobject *kobj) pr_debug("'%s' (%p): %s, parent %p\n", kobject_name(kobj), kobj, __func__, kobj->parent); + if (t && !t->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); + /* remove from sysfs if the caller did not do it */ if (kobj->state_in_sysfs) { pr_debug("'%s' (%p): auto cleanup kobject_del\n", @@ -676,13 +683,10 @@ static void kobject_cleanup(struct kobject *kobj) parent = NULL; } - if (t->release) { + if (t && t->release) { pr_debug("'%s' (%p): calling ktype release\n", kobject_name(kobj), kobj); t->release(kobj); - } else { - 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); } /* free name if we allocated it */ @@ -1056,7 +1060,7 @@ const struct kobj_ns_type_operations *kobj_child_ns_ops(const struct kobject *pa { const struct kobj_ns_type_operations *ops = NULL; - if (parent && parent->ktype->child_ns_type) + if (parent && parent->ktype && parent->ktype->child_ns_type) ops = parent->ktype->child_ns_type(parent); return ops;