From nobody Sat Feb 7 21:15:00 2026 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="BcIzvkQj" 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 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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@in= tel.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; =20 - error =3D sysfs_create_groups(kobj, ktype->default_groups); - if (error) { - sysfs_remove_dir(kobj); - return error; + if (ktype) { + error =3D sysfs_create_groups(kobj, ktype->default_groups); + if (error) { + sysfs_remove_dir(kobj); + return error; + } } =20 /* @@ -589,7 +591,8 @@ static void __kobject_del(struct kobject *kobj) sd =3D kobj->sd; ktype =3D get_ktype(kobj); =20 - sysfs_remove_groups(kobj, ktype->default_groups); + if (ktype) + sysfs_remove_groups(kobj, ktype->default_groups); =20 /* 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); =20 + if (t && !t->release) + pr_debug("'%s' (%p): does not have a release() function, it is broken an= d 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 =3D NULL; } =20 - 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 an= d must be fixed. See Documentation/core-api/kobject.rst.\n", - kobject_name(kobj), kobj); } =20 /* free name if we allocated it */ @@ -1056,7 +1060,7 @@ const struct kobj_ns_type_operations *kobj_child_ns_o= ps(const struct kobject *pa { const struct kobj_ns_type_operations *ops =3D NULL; =20 - if (parent && parent->ktype->child_ns_type) + if (parent && parent->ktype && parent->ktype->child_ns_type) ops =3D parent->ktype->child_ns_type(parent); =20 return ops; --=20 2.43.0