public inbox for linux-remoteproc@vger.kernel.org
 help / color / mirror / Atom feed
From: Chris Lew <clew@codeaurora.org>
To: Bjorn Andersson <bjorn.andersson@linaro.org>,
	Andy Gross <andy.gross@linaro.org>,
	Ohad Ben-Cohen <ohad@wizery.com>
Cc: Arun Kumar Neelakantam <aneela@codeaurora.org>,
	linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-soc@vger.kernel.org, linux-remoteproc@vger.kernel.org
Subject: Re: [PATCH v3 1/5] soc: qcom: Introduce QMI encoder/decoder
Date: Thu, 16 Nov 2017 10:57:32 -0800	[thread overview]
Message-ID: <891288a2-4a41-7cff-3662-79561f3baab2@codeaurora.org> (raw)
In-Reply-To: <20171116054252.GK28761@minitux>



On 11/15/2017 9:42 PM, Bjorn Andersson wrote:
> On Wed 15 Nov 12:10 PST 2017, Bjorn Andersson wrote:
>> diff --git a/drivers/soc/qcom/qmi_encdec.c b/drivers/soc/qcom/qmi_encdec.c
> [..]
>> +void *qmi_encode_message(int type, unsigned int msg_id, size_t *len,
>> +			 unsigned int txn_id, struct qmi_elem_info *ei,
>> +			 const void *c_struct)
>> +{
>> +	struct qmi_header *hdr;
>> +	ssize_t msglen = 0;
>> +	void *msg;
>> +	int ret;
>> +
>> +	/* Check the possibility of a zero length QMI message */
>> +	if (!c_struct) {
>> +		ret = qmi_calc_min_msg_len(ei, 1);
>> +		if (ret) {
>> +			pr_err("%s: Calc. len %d != 0, but NULL c_struct\n",
>> +			       __func__, ret);
>> +			return ERR_PTR(-EINVAL);
>> +		}
>> +	}
>> +
>> +	msg = kzalloc(sizeof(*hdr) + *len, GFP_KERNEL);
>> +	if (!msg)
>> +		return ERR_PTR(-ENOMEM);
>> +
>> +	msglen = qmi_encode(ei, msg + sizeof(*hdr), c_struct, *len, 1);
>> +	if (msglen < 0) {
>> +		kfree(msg);
>> +		return ERR_PTR(msglen);
>> +	}
> 
> Talked to Chris Lew about this earlier today;
> 
> The check above implies that it's valid to call this function with a
> valid ei of minimum message length of 0 and c_struct being NULL. But the
> call to qmi_encdec() will dereference c_struct in order to know that the
> optional elements described in ei are unset.
> 
> So the call to qmi_encode() needs to only be done conditionally on
> c_struct being non-NULL, logically interpreting c_struct being NULL as
> all optional fields are unset.
> 
> Will post an update with this fixed.
> 

I have tested this patch with QMI loopback servers, Qualcomm diag and 
slimbus ngd.

Tested-By: Chris Lew <clew@codeaurora.org>
>> +
>> +	hdr = msg;
>> +	hdr->type = type;
>> +	hdr->txn_id = txn_id;
>> +	hdr->msg_id = msg_id;
>> +	hdr->msg_len = msglen;
>> +
>> +	*len = sizeof(*hdr) + msglen;
>> +
>> +	return msg;
>> +}
>> +EXPORT_SYMBOL(qmi_encode_message);
> 
> Regards,
> Bjorn
> 

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

  reply	other threads:[~2017-11-16 18:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-15 20:10 [PATCH v3 0/5] In-kernel QMI helpers and sysmon Bjorn Andersson
2017-11-15 20:10 ` [PATCH v3 1/5] soc: qcom: Introduce QMI encoder/decoder Bjorn Andersson
2017-11-16  5:42   ` Bjorn Andersson
2017-11-16 18:57     ` Chris Lew [this message]
2017-11-16 12:10   ` Srinivas Kandagatla
2017-11-17  6:10     ` Bjorn Andersson
2017-11-15 20:10 ` [PATCH v3 2/5] soc: qcom: Introduce QMI helpers Bjorn Andersson
2017-11-16 12:11   ` Srinivas Kandagatla
2017-11-17  6:30     ` Bjorn Andersson
2017-11-18  2:11   ` Chris Lew
2017-11-21 22:42     ` Bjorn Andersson
2017-11-15 20:10 ` [PATCH v3 3/5] remoteproc: Pass type of shutdown to subdev remove Bjorn Andersson
2017-11-15 20:10 ` [PATCH v3 4/5] remoteproc: qcom: Introduce sysmon Bjorn Andersson
2017-11-16 20:05   ` Chris Lew
2017-11-17  5:58     ` Bjorn Andersson
2017-11-18  1:27       ` Chris Lew
2017-11-15 20:10 ` [PATCH v3 5/5] samples: Introduce Qualcomm QMI sample client Bjorn Andersson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=891288a2-4a41-7cff-3662-79561f3baab2@codeaurora.org \
    --to=clew@codeaurora.org \
    --cc=andy.gross@linaro.org \
    --cc=aneela@codeaurora.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=linux-soc@vger.kernel.org \
    --cc=ohad@wizery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox