MDT_BOOL_RW_ATTR macro creates a store and show methods
for a boolean sysfs entry, but in process they use result
of mdt_dev() call without checking, but internally
it uses container_of_safe that could return NULL or
ERR_PTR, so we need to check the return value.
While we can probably pass in the decoded PTR_ERR,
since NULL is also an option, simplier to just return
-ENOENT which makes sense on it's own.
Change-Id: Ibbc62cf74dc5d8b7e335fc42ff5149bd2ae174c6
Signed-off-by: Oleg Drokin <green@whamcloud.com>
Test-Parameters: trivial
Fixes:
d71a24005b753 ("LU-17144 mdt: set dmv by setxattr")
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59009
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
struct obd_device *obd = container_of(kobj, struct obd_device, \
obd_kset.kobj); \
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); \
+ if (IS_ERR_OR_NULL(mdt)) \
+ return -ENOENT; \
return scnprintf(buf, PAGE_SIZE, "%u\n", mdt->mdt_##name); \
} \
static ssize_t name##_store(struct kobject *kobj, struct attribute *attr,\
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); \
bool val; \
int rc; \
+ if (IS_ERR_OR_NULL(mdt)) \
+ return -ENOENT; \
rc = kstrtobool(buffer, &val); \
if (rc) \
return rc; \