]> www.infradead.org Git - users/jedix/linux-maple.git/commit
net: sysfs: Fix weird usage of class's namespace relevant fields
authorZijun Hu <quic_zijuhu@quicinc.com>
Wed, 4 Sep 2024 23:35:38 +0000 (07:35 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 9 Sep 2024 09:30:52 +0000 (10:30 +0100)
commit8f088541991bc1716a5ed570456d218241303851
tree5ca7c44ff2e736e649a64ed74ce9fcb5b9a0fc98
parent4897313bdb2b82c83e3c52c9549ee293c4e47da6
net: sysfs: Fix weird usage of class's namespace relevant fields

Device class has two namespace relevant fields which are associated by
the following usage:

struct class {
...
const struct kobj_ns_type_operations *ns_type;
const void *(*namespace)(const struct device *dev);
...
}
if (dev->class && dev->class->ns_type)
dev->class->namespace(dev);

The usage looks weird since it checks @ns_type but calls namespace()
it is found for all existing class definitions that the other filed is
also assigned once one is assigned in current kernel tree, so fix this
weird usage by checking @namespace to call namespace().

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/net-sysfs.c