All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: nsp: off by ones in nsp_pinmux_enable()
@ 2018-07-03 12:04 Dan Carpenter
  2018-07-03 16:47 ` Ray Jui
  2018-07-09 13:29 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2018-07-03 12:04 UTC (permalink / raw)
  To: kernel-janitors

The > comparisons should be >= or else we read beyond the end of the
pinctrl->functions[] array.

Fixes: cc4fa83f66e9 ("pinctrl: nsp: add pinmux driver support for Broadcom NSP SoC")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-mux.c b/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
index 35c17653c694..5cd8166fbbc8 100644
--- a/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
+++ b/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
@@ -460,8 +460,8 @@ static int nsp_pinmux_enable(struct pinctrl_dev *pctrl_dev,
 	const struct nsp_pin_function *func;
 	const struct nsp_pin_group *grp;
 
-	if (grp_select > pinctrl->num_groups ||
-		func_select > pinctrl->num_functions)
+	if (grp_select >= pinctrl->num_groups ||
+	    func_select >= pinctrl->num_functions)
 		return -EINVAL;
 
 	func = &pinctrl->functions[func_select];

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] pinctrl: nsp: off by ones in nsp_pinmux_enable()
  2018-07-03 12:04 [PATCH] pinctrl: nsp: off by ones in nsp_pinmux_enable() Dan Carpenter
@ 2018-07-03 16:47 ` Ray Jui
  2018-07-09 13:29 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Ray Jui @ 2018-07-03 16:47 UTC (permalink / raw)
  To: kernel-janitors

Hi Dan,

On 7/3/2018 5:04 AM, Dan Carpenter wrote:
> The > comparisons should be >= or else we read beyond the end of the
> pinctrl->functions[] array.
> 
> Fixes: cc4fa83f66e9 ("pinctrl: nsp: add pinmux driver support for Broadcom NSP SoC")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-mux.c b/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
> index 35c17653c694..5cd8166fbbc8 100644
> --- a/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
> +++ b/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
> @@ -460,8 +460,8 @@ static int nsp_pinmux_enable(struct pinctrl_dev *pctrl_dev,
>   	const struct nsp_pin_function *func;
>   	const struct nsp_pin_group *grp;
>   
> -	if (grp_select > pinctrl->num_groups ||
> -		func_select > pinctrl->num_functions)
> +	if (grp_select >= pinctrl->num_groups ||
> +	    func_select >= pinctrl->num_functions)
>   		return -EINVAL;
>   
>   	func = &pinctrl->functions[func_select];
> 

Fix looks good to me. Thanks!

Reviewed-by: Ray Jui <ray.jui@broadcom.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] pinctrl: nsp: off by ones in nsp_pinmux_enable()
  2018-07-03 12:04 [PATCH] pinctrl: nsp: off by ones in nsp_pinmux_enable() Dan Carpenter
  2018-07-03 16:47 ` Ray Jui
@ 2018-07-09 13:29 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2018-07-09 13:29 UTC (permalink / raw)
  To: kernel-janitors

On Tue, Jul 3, 2018 at 2:04 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:

> The > comparisons should be >= or else we read beyond the end of the
> pinctrl->functions[] array.
>
> Fixes: cc4fa83f66e9 ("pinctrl: nsp: add pinmux driver support for Broadcom NSP SoC")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Patch applied with Ray's ACK for fixes.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-09 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-03 12:04 [PATCH] pinctrl: nsp: off by ones in nsp_pinmux_enable() Dan Carpenter
2018-07-03 16:47 ` Ray Jui
2018-07-09 13:29 ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.