From ee7232eeec86e650278911aad4e7407d1a8e78c1 Mon Sep 17 00:00:00 2001 From: wenfei Date: Mon, 10 Oct 2022 13:28:32 +0800 Subject: [PATCH] fix hmdfs tscan warning Signed-off-by: wenfei --- fs/hmdfs/comm/device_node.c | 7 ++++--- fs/hmdfs/comm/transport.c | 3 +-- fs/hmdfs/file_remote.c | 2 +- fs/hmdfs/hmdfs_client.c | 5 +++-- fs/hmdfs/hmdfs_dentryfile.c | 2 ++ 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/fs/hmdfs/comm/device_node.c b/fs/hmdfs/comm/device_node.c index c6bf56086400..7c2bac914bb4 100644 --- a/fs/hmdfs/comm/device_node.c +++ b/fs/hmdfs/comm/device_node.c @@ -65,9 +65,10 @@ static void ctrl_cmd_update_socket_handler(const char *buf, size_t len, else hmdfs_check_cred(system_cred); } -out: + if (conn) connection_put(conn); +out: if (node) peer_put(node); } @@ -1339,7 +1340,7 @@ static ssize_t cmd_timeout_show(struct kobject *kobj, struct attribute *attr, int cmd = to_sbi_cmd_attr(attr)->command; struct hmdfs_sb_info *sbi = cmd_kobj_to_sbi(kobj); - if (cmd < 0 && cmd >= F_SIZE) + if (cmd < 0 || cmd >= F_SIZE) return 0; return snprintf(buf, PAGE_SIZE, "%u\n", get_cmd_timeout(sbi, cmd)); @@ -1353,7 +1354,7 @@ static ssize_t cmd_timeout_store(struct kobject *kobj, struct attribute *attr, int ret = kstrtouint(skip_spaces(buf), 0, &value); struct hmdfs_sb_info *sbi = cmd_kobj_to_sbi(kobj); - if (cmd < 0 && cmd >= F_SIZE) + if (cmd < 0 || cmd >= F_SIZE) return -EINVAL; if (!ret) diff --git a/fs/hmdfs/comm/transport.c b/fs/hmdfs/comm/transport.c index 07dd3205c62b..c9eaaa7dca37 100644 --- a/fs/hmdfs/comm/transport.c +++ b/fs/hmdfs/comm/transport.c @@ -1055,8 +1055,7 @@ void hmdfs_reget_connection(struct connection *conn) * To avoid the receive thread to stop itself. Ensure receive * thread stop before process offline event */ - if (!recv_task || - (recv_task && (recv_task->pid == current->pid))) + if (!recv_task || recv_task->pid == current->pid) stop_thread = false; } mutex_unlock(&conn->node->conn_impl_list_lock); diff --git a/fs/hmdfs/file_remote.c b/fs/hmdfs/file_remote.c index e1a450ef2145..f9a77ddf4dcc 100644 --- a/fs/hmdfs/file_remote.c +++ b/fs/hmdfs/file_remote.c @@ -356,7 +356,7 @@ int hmdfs_file_open_remote(struct inode *inode, struct file *file) static void hmdfs_set_writecache_expire(struct hmdfs_inode_info *info, unsigned int seconds) { - unsigned long new_expire = jiffies + seconds * HZ; + unsigned long new_expire = jiffies + (unsigned long)seconds * HZ; /* * When file has been written before closing, set pagecache expire diff --git a/fs/hmdfs/hmdfs_client.c b/fs/hmdfs/hmdfs_client.c index 2c381f57f7e0..31c1a6d38e8f 100644 --- a/fs/hmdfs/hmdfs_client.c +++ b/fs/hmdfs/hmdfs_client.c @@ -900,9 +900,10 @@ int hmdfs_send_setxattr(struct hmdfs_peer *con, const char *send_buf, req->flags = cpu_to_le32(flags); strncpy(req->buf, send_buf, path_len); strncpy(req->buf + path_len + 1, name, name_len); - memcpy(req->buf + path_len + name_len + 2, value, size); - if (!value) + if (!value) { + memcpy(req->buf + path_len + name_len + 2, value, size); req->del = true; + } ret = hmdfs_sendmessage_request(con, &sm); kfree(req); return ret; diff --git a/fs/hmdfs/hmdfs_dentryfile.c b/fs/hmdfs/hmdfs_dentryfile.c index 3455b91b4d61..1a65e3fc479c 100644 --- a/fs/hmdfs/hmdfs_dentryfile.c +++ b/fs/hmdfs/hmdfs_dentryfile.c @@ -2457,6 +2457,8 @@ int hmdfs_root_unlink(uint64_t device_id, struct path *root_path, goto unlock_out; } child_inode = d_inode(child_dentry); + if (!child_inode) + goto unlock_out; tmp_uid = hmdfs_override_inode_uid(dir); -- Gitee