interconnect: debugfs: Fix incorrect error handling for NULL path
PATCH 1/1 interconnect: debugfs: Fix incorrect error handling for NULL path
The icc_commit_set() function, used by the debugfs interface, checks the validity of the global cur_path pointer using IS_ERR_OR_NULL(). However, in the specific case where cur_path is NULL, while IS_ERR_OR_NULL(NULL) correctly evaluates to true, the subsequent call to PTR_ERR(NULL) returns 0.
This causes the function to return a success code (0) instead of an error, misleading the user into believing their bandwidth request was successfully committed when, in fact, no operation was performed.
Fix this by adding an explicit check to return -EINVAL if cur_path is NULL. This prevents silent failures and ensures that an invalid operational sequence is immediately and clearly reported as an error.
--- drivers/interconnect/debugfs-client.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/interconnect/debugfs-client.c +6 -1
@@ -117,7 +117,12 @@ static int icc_commit_set(void *data, u64 val)mutex_lock (&debugfs_lock); -if (IS_ERR_OR_NULL (cur_path)) { +if (!cur_path) { + ret = -EINVAL ; + goto out; + } + +if (IS_ERR (cur_path)) { ret =PTR_ERR (cur_path); goto out; }
Signature · 1 line
2.34.1