From ab9c373119ab869a1af55a7703a5f29c8fffa480 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Thu, 26 Sep 2019 23:23:54 -0700 Subject: [PATCH] soc: qcom: glink_debugfs: Fix strlcpy usage Clang warns: ../drivers/soc/qcom/glink_debugfs.c:562:18: warning: size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination [-Wstrlcpy-strlcat-size] curr, strlen(curr) + 1); ~~~~~~~^~~~~~~~~ ../drivers/soc/qcom/glink_debugfs.c:562:11: note: change size argument to be the size of the destination curr, strlen(curr) + 1); ^~~~~~~~~~~~~~~~ sizeof(dbgfs_dent_s->self_name) ../drivers/soc/qcom/glink_debugfs.c:564:13: warning: size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination [-Wstrlcpy-strlcat-size] strlen(par_dir) + 1); ~~~~~~~^~~~~~~~~~~~ ../drivers/soc/qcom/glink_debugfs.c:564:6: note: change size argument to be the size of the destination strlen(par_dir) + 1); ^~~~~~~~~~~~~~~~~~~ sizeof(dbgfs_dent_s->par_name) 2 warnings generated. Fixes: 987bbebd9aa6 ("soc: qcom: Add snapshot of G-Link driver") Signed-off-by: Nathan Chancellor --- drivers/soc/qcom/glink_debugfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/soc/qcom/glink_debugfs.c b/drivers/soc/qcom/glink_debugfs.c index 8e65e4ac9b8e..62d68171bb10 100644 --- a/drivers/soc/qcom/glink_debugfs.c +++ b/drivers/soc/qcom/glink_debugfs.c @@ -558,10 +558,10 @@ void glink_dfs_update_list(struct dentry *curr_dent, struct dentry *parent, spin_lock_init(&dbgfs_dent_s->file_list_lock_lhb0); dbgfs_dent_s->parent = parent; dbgfs_dent_s->self = curr_dent; - strlcpy(dbgfs_dent_s->self_name, - curr, strlen(curr) + 1); - strlcpy(dbgfs_dent_s->par_name, par_dir, - strlen(par_dir) + 1); + strscpy(dbgfs_dent_s->self_name, curr, + sizeof(dbgfs_dent_s->self_name)); + strscpy(dbgfs_dent_s->par_name, par_dir, + sizeof(dbgfs_dent_s->par_name)); mutex_lock(&dent_list_lock_lha0); list_add_tail(&dbgfs_dent_s->list_node, &dent_list); mutex_unlock(&dent_list_lock_lha0); -- 2.11.0