From: bbhatt@codeaurora.org
To: Jeffrey Hugo <jhugo@codeaurora.org>
Cc: mani@kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, hemantk@codeaurora.org,
linux-arm-msm-owner@vger.kernel.org
Subject: Re: [PATCH v3 6/9] bus: mhi: core: WARN_ON for malformed vector table
Date: Fri, 01 May 2020 19:38:52 -0700 [thread overview]
Message-ID: <4d26ba11678e0302a0e6199b2b393cc2@codeaurora.org> (raw)
In-Reply-To: <15f88b7a-a3cb-ac19-bffe-247f2e99d894@codeaurora.org>
On 2020-04-30 08:02, Jeffrey Hugo wrote:
> On 4/29/2020 2:52 PM, Bhaumik Bhatt wrote:
>> Add a bounds check in the firmware copy routine to exit if a malformed
>> vector table is found while attempting to load the firmware in to the
>> BHIe vector table.
>>
>> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
>> ---
>> drivers/bus/mhi/core/boot.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/bus/mhi/core/boot.c b/drivers/bus/mhi/core/boot.c
>> index 17c636b..bc70edc 100644
>> --- a/drivers/bus/mhi/core/boot.c
>> +++ b/drivers/bus/mhi/core/boot.c
>> @@ -362,8 +362,14 @@ static void mhi_firmware_copy(struct
>> mhi_controller *mhi_cntrl,
>> int i = 0;
>> struct mhi_buf *mhi_buf = img_info->mhi_buf;
>> struct bhi_vec_entry *bhi_vec = img_info->bhi_vec;
>> + struct device *dev = &mhi_cntrl->mhi_dev->dev;
>> while (remainder) {
>> + if (WARN_ON(i >= img_info->entries)) {
>> + dev_err(dev, "Malformed vector table\n");
>
> I feel like this message needs more detail. At a minimum, I think it
> should indicate what vector table (BHIe). I think if you can identify
> what file, etc the the glitch is in, that would be better. Maybe some
> detail about i and img_info->entries.
>
> If I see this error message, I should have enough information to
> immediately debug the issue. If it tells enough to go directly into
> the firmware file and have a look at entry X to see what might be
> corrupt about it, that makes my debugging very efficient. If I have
> to go back to the code to figure out what "Malformed vector table"
> means, and then maybe apply a patch to get more data about the error -
> the error message is not as useful as it should be.
>
I plan on dropping this patch as it looks like an unnecessary check
since we
will always rely on the firmware->size from the request_firmware() API
in order
to calculate the img_info->entries (or we can call it the number of
segments, in
our case). And we will never fail in the if loop as values will already
be
bounded.
>> + return;
>> + }
>> +
>> to_cpy = min(remainder, mhi_buf->len);
>> memcpy(mhi_buf->buf, buf, to_cpy);
>> bhi_vec->dma_addr = mhi_buf->dma_addr;
>>
next prev parent reply other threads:[~2020-05-02 2:39 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-29 20:52 [PATCH v3 0/9] Bug fixes and improved logging in MHI Bhaumik Bhatt
2020-04-29 20:52 ` [PATCH v3 1/9] bus: mhi: core: Refactor mhi queue APIs Bhaumik Bhatt
2020-04-30 14:22 ` Jeffrey Hugo
2020-04-29 20:52 ` [PATCH v3 2/9] bus: mhi: core: Cache intmod from mhi event to mhi channel Bhaumik Bhatt
2020-04-30 14:23 ` Jeffrey Hugo
2020-04-29 20:52 ` [PATCH v3 3/9] bus: mhi: core: Add range check for channel id received in event ring Bhaumik Bhatt
2020-04-30 14:26 ` Jeffrey Hugo
2020-04-29 20:52 ` [PATCH v3 4/9] bus: mhi: core: Read transfer length from an event properly Bhaumik Bhatt
2020-04-30 14:28 ` Jeffrey Hugo
2020-04-29 20:52 ` [PATCH v3 5/9] bus: mhi: core: Handle firmware load using state worker Bhaumik Bhatt
2020-04-30 14:50 ` Jeffrey Hugo
2020-04-29 20:52 ` [PATCH v3 6/9] bus: mhi: core: WARN_ON for malformed vector table Bhaumik Bhatt
2020-04-30 15:02 ` Jeffrey Hugo
2020-05-02 2:38 ` bbhatt [this message]
2020-04-29 20:52 ` [PATCH v3 7/9] bus: mhi: core: Return appropriate error codes for AMSS load failure Bhaumik Bhatt
2020-04-30 15:03 ` Jeffrey Hugo
2020-04-29 20:52 ` [PATCH v3 8/9] bus: mhi: core: Improve debug logs for loading firmware Bhaumik Bhatt
2020-04-30 15:06 ` Jeffrey Hugo
2020-04-29 20:52 ` [PATCH v3 9/9] bus: mhi: core: Ensure non-zero session or sequence ID values Bhaumik Bhatt
2020-04-30 15:12 ` Jeffrey Hugo
2020-05-02 2:33 ` bbhatt
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=4d26ba11678e0302a0e6199b2b393cc2@codeaurora.org \
--to=bbhatt@codeaurora.org \
--cc=hemantk@codeaurora.org \
--cc=jhugo@codeaurora.org \
--cc=linux-arm-msm-owner@vger.kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mani@kernel.org \
/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