diff --git a/fs/hmdfs/comm/device_node.c b/fs/hmdfs/comm/device_node.c index c6bf560864008355f2c0cfa65f4e046d046302b9..7c2bac914bb46b37a14b4623d6dcd38ac0d34873 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 07dd3205c62b0bf430fee5298850d28325a8bce0..c9eaaa7dca376fc284dbd1435efda428162df1a6 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 e1a450ef2145f744dcd4101b0feb72a67c038367..f9a77ddf4dccfd5b6e0ed3d30d220e547ac4e192 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 2c381f57f7e01352749244550c535fa51a4e5b9b..31c1a6d38e8fa4c228f695808e135fce4fa5b123 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 3455b91b4d6153392cdb080a8ff3b58d2ada5a2d..1a65e3fc479c0beaeb3ce0930bcfff1a558d510e 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);