mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mukesh Ojha <mojha@codeaurora.org>
To: Colin King <colin.king@canonical.com>,
	Mark Brown <broonie@kernel.org>,
	linux-spi@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] spi: oc-tiny: fix negative loop bound error on for loop
Date: Sun, 31 Mar 2019 14:54:16 +0530	[thread overview]
Message-ID: <88c53375-5727-c865-05ba-829b6e7d5128@codeaurora.org> (raw)
In-Reply-To: <20190330212300.11675-1-colin.king@canonical.com>


On 3/31/2019 2:53 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the for-loop using an unsigned int for the loop counter
> which is problematic when comparing it to the signed int
> gt->gpio_cs_count.  This is an issue because if the signed int is
> negative (for example, the call to of_gpio_count failed) then
> the negative loop bound is implicitly cast to an unsigned int on
> the comparison to loop counter i and will yield a very large value,
> eventually causing an array bounds overflow on hw->gpio_cs.
>
> Fix this by simply making the loop counter i a signed int;
>
> Fixes: ca632f556697 ("spi: reorganize drivers")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   drivers/spi/spi-oc-tiny.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi-oc-tiny.c b/drivers/spi/spi-oc-tiny.c
> index 085f580be7ec..81f74b938dc9 100644
> --- a/drivers/spi/spi-oc-tiny.c
> +++ b/drivers/spi/spi-oc-tiny.c
> @@ -206,7 +206,7 @@ static int tiny_spi_of_probe(struct platform_device *pdev)
>   {
>   	struct tiny_spi *hw = platform_get_drvdata(pdev);
>   	struct device_node *np = pdev->dev.of_node;
> -	unsigned int i;
> +	int i;


Same issue, here as well like your other patch. you are putting wrapper 
over a original issue by not checking the returned value.
Please fix that in both patches.



Thanks.
Mukesh

>   	u32 val;
>   
>   	if (!np)

  parent reply	other threads:[~2019-03-31  9:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-30 21:23 Colin King
2019-03-31  9:23 ` Mukesh Ojha
2019-03-31  9:24 ` Mukesh Ojha [this message]
2019-04-01  3:19 ` Mark Brown

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=88c53375-5727-c865-05ba-829b6e7d5128@codeaurora.org \
    --to=mojha@codeaurora.org \
    --cc=broonie@kernel.org \
    --cc=colin.king@canonical.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.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

all inboxes | Powered by JetHome®