[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <15f88b7a-a3cb-ac19-bffe-247f2e99d894@codeaurora.org>
Date: Thu, 30 Apr 2020 09:02:19 -0600
From: Jeffrey Hugo <jhugo@...eaurora.org>
To: Bhaumik Bhatt <bbhatt@...eaurora.org>, mani@...nel.org
Cc: linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org,
hemantk@...eaurora.org
Subject: Re: [PATCH v3 6/9] bus: mhi: core: WARN_ON for malformed vector table
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@...eaurora.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.
> + return;
> + }
> +
> to_cpy = min(remainder, mhi_buf->len);
> memcpy(mhi_buf->buf, buf, to_cpy);
> bhi_vec->dma_addr = mhi_buf->dma_addr;
>
--
Jeffrey Hugo
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
Powered by blists - more mailing lists