Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Revert "kobject: Remove redundant checks for whether ktype is NULL"

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 <oliver.sang@intel.com>
Fixes: 1b28cb81dab7 ("kobject: Remove redundant checks for whether ktype is NULL")
Cc: Zhen Lei <thunder.leizhen@huawei.com>
Closes: https://lore.kernel.org/oe-lkp/202402071403.e302e33a-oliver.sang@intel.com
Link: https://lore.kernel.org/r/2024020849-consensus-length-6264@gregkh
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+14 -10
+14 -10
lib/kobject.c
··· 74 74 if (error) 75 75 return error; 76 76 77 - error = sysfs_create_groups(kobj, ktype->default_groups); 78 - if (error) { 79 - sysfs_remove_dir(kobj); 80 - return error; 77 + if (ktype) { 78 + error = sysfs_create_groups(kobj, ktype->default_groups); 79 + if (error) { 80 + sysfs_remove_dir(kobj); 81 + return error; 82 + } 81 83 } 82 84 83 85 /* ··· 591 589 sd = kobj->sd; 592 590 ktype = get_ktype(kobj); 593 591 594 - sysfs_remove_groups(kobj, ktype->default_groups); 592 + if (ktype) 593 + sysfs_remove_groups(kobj, ktype->default_groups); 595 594 596 595 /* send "remove" if the caller did not do it but sent "add" */ 597 596 if (kobj->state_add_uevent_sent && !kobj->state_remove_uevent_sent) { ··· 669 666 pr_debug("'%s' (%p): %s, parent %p\n", 670 667 kobject_name(kobj), kobj, __func__, kobj->parent); 671 668 669 + if (t && !t->release) 670 + pr_debug("'%s' (%p): does not have a release() function, it is broken and must be fixed. See Documentation/core-api/kobject.rst.\n", 671 + kobject_name(kobj), kobj); 672 + 672 673 /* remove from sysfs if the caller did not do it */ 673 674 if (kobj->state_in_sysfs) { 674 675 pr_debug("'%s' (%p): auto cleanup kobject_del\n", ··· 683 676 parent = NULL; 684 677 } 685 678 686 - if (t->release) { 679 + if (t && t->release) { 687 680 pr_debug("'%s' (%p): calling ktype release\n", 688 681 kobject_name(kobj), kobj); 689 682 t->release(kobj); 690 - } else { 691 - pr_debug("'%s' (%p): does not have a release() function, it is broken and must be fixed. See Documentation/core-api/kobject.rst.\n", 692 - kobject_name(kobj), kobj); 693 683 } 694 684 695 685 /* free name if we allocated it */ ··· 1060 1056 { 1061 1057 const struct kobj_ns_type_operations *ops = NULL; 1062 1058 1063 - if (parent && parent->ktype->child_ns_type) 1059 + if (parent && parent->ktype && parent->ktype->child_ns_type) 1064 1060 ops = parent->ktype->child_ns_type(parent); 1065 1061 1066 1062 return ops;