Whamcloud - gitweb
LU-18961 mdt: add safety checks in MDT_BOOL_RW_ATTR 09/59009/2
authorOleg Drokin <green@whamcloud.com>
Tue, 29 Apr 2025 04:05:27 +0000 (00:05 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 7 May 2025 21:14:29 +0000 (21:14 +0000)
commit117be08e587cac3021b7f4ddb2428eb1178b01cb
tree35a4a1d7deaf60baf42cf1bda7b904f87885a69d
parent77af7e129bd959d9e182c5ce3992288ce9639f72
LU-18961 mdt: add safety checks in MDT_BOOL_RW_ATTR

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>
lustre/mdt/mdt_lproc.c