Re: [PATCH v7 08/13] ksmbd: add smb3 engine part 1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 05, 2021 at 03:05:41PM +0900, Namjae Jeon wrote:
> +/**
> + * check_session_id() - check for valid session id in smb header
> + * @conn:	connection instance
> + * @id:		session id from smb header
> + *
> + * Return:      1 if valid session id, otherwise 0
> + */
> +static inline int check_session_id(struct ksmbd_conn *conn, u64 id)

Make this bool.  Same for all the is_* functions.

> +{
> +	struct ksmbd_session *sess;
> +
> +	if (id == 0 || id == -1)
> +		return 0;
> +
> +	sess = ksmbd_session_lookup_all(conn, id);
> +	if (sess)
> +		return 1;
> +	pr_err("Invalid user session id: %llu\n", id);
> +	return 0;
> +}
> +
> +struct channel *lookup_chann_list(struct ksmbd_session *sess, struct ksmbd_conn *conn)
> +{
> +	struct channel *chann;
> +
> +	list_for_each_entry(chann, &sess->ksmbd_chann_list, chann_list) {
> +		if (chann->conn == conn)
> +			return chann;
> +	}
> +
> +	return NULL;
> +}
> +
> +/**
> + * smb2_get_ksmbd_tcon() - get tree connection information for a tree id
> + * @work:	smb work
> + *
> + * Return:      matching tree connection on success, otherwise error

This documentation seems out of date.

> + */
> +int smb2_get_ksmbd_tcon(struct ksmbd_work *work)
> +{
> +	struct smb2_hdr *req_hdr = work->request_buf;
> +	int tree_id;
> +
> +	work->tcon = NULL;
> +	if (work->conn->ops->get_cmd_val(work) == SMB2_TREE_CONNECT_HE ||
> +	    work->conn->ops->get_cmd_val(work) ==  SMB2_CANCEL_HE ||
> +	    work->conn->ops->get_cmd_val(work) ==  SMB2_LOGOFF_HE) {
> +		ksmbd_debug(SMB, "skip to check tree connect request\n");
> +		return 0;
> +	}
> +
> +	if (xa_empty(&work->sess->tree_conns)) {
> +		ksmbd_debug(SMB, "NO tree connected\n");
> +		return -1;

Better to return -EINVAL.

> +	}
> +
> +	tree_id = le32_to_cpu(req_hdr->Id.SyncId.TreeId);
> +	work->tcon = ksmbd_tree_conn_lookup(work->sess, tree_id);
> +	if (!work->tcon) {
> +		pr_err("Invalid tid %d\n", tree_id);
> +		return -1;
> +	}
> +
> +	return 1;
> +}

regards,
dan carpenter



[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux