Re: [PATCH 2/4] soc: qcom: aoss: Add debugfs interface for sending messages

From: Konrad Dybcio
Date: Mon Jul 31 2023 - 04:18:51 EST


On 31.07.2023 06:10, Bjorn Andersson wrote:
> From: Chris Lew <clew@xxxxxxxxxxxxxx>
No QUIC email?

[...]


> +static ssize_t qmp_debugfs_write(struct file *file, const char __user *userstr,
> + size_t len, loff_t *pos)
> +{
> + struct qmp *qmp = file->private_data;
> + char buf[QMP_MSG_LEN];
> + int ret;
> +
> + if (!len || len > QMP_MSG_LEN)
>=? Otherwise the last char may be overwritten by the NULL termination
couple lines below

> + return -EINVAL;
> +
> + if (copy_from_user(buf, userstr, len))
> + return -EFAULT;
> + buf[len] = '\0';
> +
> + ret = qmp_send(qmp, buf);
> + if (ret < 0)
> + return ret;
> +
> + return len;
> +}
Konrad