linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] phy: renesas: phy-rcar-gen2: Fix the array off by one warning
@ 2019-05-16 13:22 Biju Das
  2019-05-16 13:51 ` Wolfram Sang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Biju Das @ 2019-05-16 13:22 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Biju Das, Simon Horman, Yoshihiro Shimoda, Wolfram Sang,
	Simon Horman, Geert Uytterhoeven, Chris Paterson,
	Fabrizio Castro, linux-renesas-soc

Fix the below smatch warning by adding variable check rather than the
hardcoded value.
warn: array off by one? 'data->select_value[channel_num]'

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
V1-->V2 
  * Incorporated Geert's review comments.
    (https://patchwork.kernel.org/patch/10944837/)
---
 drivers/phy/renesas/phy-rcar-gen2.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/renesas/phy-rcar-gen2.c b/drivers/phy/renesas/phy-rcar-gen2.c
index 8dc5710..8dbdc5b 100644
--- a/drivers/phy/renesas/phy-rcar-gen2.c
+++ b/drivers/phy/renesas/phy-rcar-gen2.c
@@ -71,6 +71,7 @@ struct rcar_gen2_phy_driver {
 struct rcar_gen2_phy_data {
 	const struct phy_ops *gen2_phy_ops;
 	const u32 (*select_value)[PHYS_PER_CHANNEL];
+	const u32 num_channels;
 };
 
 static int rcar_gen2_phy_init(struct phy *p)
@@ -271,11 +272,13 @@ static const u32 usb20_select_value[][PHYS_PER_CHANNEL] = {
 static const struct rcar_gen2_phy_data rcar_gen2_usb_phy_data = {
 	.gen2_phy_ops = &rcar_gen2_phy_ops,
 	.select_value = pci_select_value,
+	.num_channels = ARRAY_SIZE(pci_select_value),
 };
 
 static const struct rcar_gen2_phy_data rz_g1c_usb_phy_data = {
 	.gen2_phy_ops = &rz_g1c_phy_ops,
 	.select_value = usb20_select_value,
+	.num_channels = ARRAY_SIZE(usb20_select_value),
 };
 
 static const struct of_device_id rcar_gen2_phy_match_table[] = {
@@ -389,7 +392,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
 		channel->selected_phy = -1;
 
 		error = of_property_read_u32(np, "reg", &channel_num);
-		if (error || channel_num > 2) {
+		if (error || channel_num >= data->num_channels) {
 			dev_err(dev, "Invalid \"reg\" property\n");
 			return error;
 		}
-- 
2.7.4


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

* Re: [PATCH v2] phy: renesas: phy-rcar-gen2: Fix the array off by one warning
  2019-05-16 13:22 [PATCH v2] phy: renesas: phy-rcar-gen2: Fix the array off by one warning Biju Das
@ 2019-05-16 13:51 ` Wolfram Sang
  2019-05-17 13:25 ` Ulrich Hecht
  2019-05-21  7:03 ` Yoshihiro Shimoda
  2 siblings, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2019-05-16 13:51 UTC (permalink / raw)
  To: Biju Das
  Cc: Kishon Vijay Abraham I, Simon Horman, Yoshihiro Shimoda,
	Wolfram Sang, Simon Horman, Geert Uytterhoeven, Chris Paterson,
	Fabrizio Castro, linux-renesas-soc

[-- Attachment #1: Type: text/plain, Size: 454 bytes --]

On Thu, May 16, 2019 at 02:22:03PM +0100, Biju Das wrote:
> Fix the below smatch warning by adding variable check rather than the
> hardcoded value.
> warn: array off by one? 'data->select_value[channel_num]'
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v2] phy: renesas: phy-rcar-gen2: Fix the array off by one warning
  2019-05-16 13:22 [PATCH v2] phy: renesas: phy-rcar-gen2: Fix the array off by one warning Biju Das
  2019-05-16 13:51 ` Wolfram Sang
@ 2019-05-17 13:25 ` Ulrich Hecht
  2019-05-21  7:03 ` Yoshihiro Shimoda
  2 siblings, 0 replies; 7+ messages in thread
From: Ulrich Hecht @ 2019-05-17 13:25 UTC (permalink / raw)
  To: Biju Das, Kishon Vijay Abraham I
  Cc: Simon Horman, Yoshihiro Shimoda, Wolfram Sang, Simon Horman,
	Geert Uytterhoeven, Chris Paterson, Fabrizio Castro,
	linux-renesas-soc


> On May 16, 2019 at 3:22 PM Biju Das <biju.das@bp.renesas.com> wrote:
> 
> 
> Fix the below smatch warning by adding variable check rather than the
> hardcoded value.
> warn: array off by one? 'data->select_value[channel_num]'
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> V1-->V2 
>   * Incorporated Geert's review comments.
>     (https://patchwork.kernel.org/patch/10944837/)
> ---
>  drivers/phy/renesas/phy-rcar-gen2.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/renesas/phy-rcar-gen2.c b/drivers/phy/renesas/phy-rcar-gen2.c
> index 8dc5710..8dbdc5b 100644
> --- a/drivers/phy/renesas/phy-rcar-gen2.c
> +++ b/drivers/phy/renesas/phy-rcar-gen2.c
> @@ -71,6 +71,7 @@ struct rcar_gen2_phy_driver {
>  struct rcar_gen2_phy_data {
>  	const struct phy_ops *gen2_phy_ops;
>  	const u32 (*select_value)[PHYS_PER_CHANNEL];
> +	const u32 num_channels;
>  };
>  
>  static int rcar_gen2_phy_init(struct phy *p)
> @@ -271,11 +272,13 @@ static const u32 usb20_select_value[][PHYS_PER_CHANNEL] = {
>  static const struct rcar_gen2_phy_data rcar_gen2_usb_phy_data = {
>  	.gen2_phy_ops = &rcar_gen2_phy_ops,
>  	.select_value = pci_select_value,
> +	.num_channels = ARRAY_SIZE(pci_select_value),
>  };
>  
>  static const struct rcar_gen2_phy_data rz_g1c_usb_phy_data = {
>  	.gen2_phy_ops = &rz_g1c_phy_ops,
>  	.select_value = usb20_select_value,
> +	.num_channels = ARRAY_SIZE(usb20_select_value),
>  };
>  
>  static const struct of_device_id rcar_gen2_phy_match_table[] = {
> @@ -389,7 +392,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
>  		channel->selected_phy = -1;
>  
>  		error = of_property_read_u32(np, "reg", &channel_num);
> -		if (error || channel_num > 2) {
> +		if (error || channel_num >= data->num_channels) {
>  			dev_err(dev, "Invalid \"reg\" property\n");
>  			return error;
>  		}
> -- 
> 2.7.4
>

Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>

CU
Uli

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

* RE: [PATCH v2] phy: renesas: phy-rcar-gen2: Fix the array off by one warning
  2019-05-16 13:22 [PATCH v2] phy: renesas: phy-rcar-gen2: Fix the array off by one warning Biju Das
  2019-05-16 13:51 ` Wolfram Sang
  2019-05-17 13:25 ` Ulrich Hecht
@ 2019-05-21  7:03 ` Yoshihiro Shimoda
  2019-10-01  6:39   ` Biju Das
  2 siblings, 1 reply; 7+ messages in thread
From: Yoshihiro Shimoda @ 2019-05-21  7:03 UTC (permalink / raw)
  To: Biju Das, Kishon Vijay Abraham I
  Cc: Biju Das, Simon Horman, Wolfram Sang, Simon Horman,
	Geert Uytterhoeven, Chris Paterson, Fabrizio Castro,
	linux-renesas-soc

Hi Biju-san,

> From: Biju Das, Sent: Thursday, May 16, 2019 10:22 PM
> 
> Fix the below smatch warning by adding variable check rather than the
> hardcoded value.
> warn: array off by one? 'data->select_value[channel_num]'
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Thank you for the patch!

Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Best regards,
Yoshihiro Shimoda


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

* RE: [PATCH v2] phy: renesas: phy-rcar-gen2: Fix the array off by one warning
  2019-05-21  7:03 ` Yoshihiro Shimoda
@ 2019-10-01  6:39   ` Biju Das
  2019-10-09 12:54     ` Kishon Vijay Abraham I
  0 siblings, 1 reply; 7+ messages in thread
From: Biju Das @ 2019-10-01  6:39 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Simon Horman, Wolfram Sang, Simon Horman, Geert Uytterhoeven,
	Chris Paterson, Fabrizio Castro, linux-renesas-soc,
	Yoshihiro Shimoda

Hello Kishon,

Are you happy with this patch? Please let me know.

https://patchwork.kernel.org/patch/10946601/


Regards,
Biju

> Subject: RE: [PATCH v2] phy: renesas: phy-rcar-gen2: Fix the array off by one
> warning
> 
> Hi Biju-san,
> 
> > From: Biju Das, Sent: Thursday, May 16, 2019 10:22 PM
> >
> > Fix the below smatch warning by adding variable check rather than the
> > hardcoded value.
> > warn: array off by one? 'data->select_value[channel_num]'
> >
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> > Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> Thank you for the patch!
> 
> Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> 
> Best regards,
> Yoshihiro Shimoda


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

* Re: [PATCH v2] phy: renesas: phy-rcar-gen2: Fix the array off by one warning
  2019-10-01  6:39   ` Biju Das
@ 2019-10-09 12:54     ` Kishon Vijay Abraham I
  2019-10-09 13:01       ` Biju Das
  0 siblings, 1 reply; 7+ messages in thread
From: Kishon Vijay Abraham I @ 2019-10-09 12:54 UTC (permalink / raw)
  To: Biju Das
  Cc: Simon Horman, Wolfram Sang, Simon Horman, Geert Uytterhoeven,
	Chris Paterson, Fabrizio Castro, linux-renesas-soc,
	Yoshihiro Shimoda

Hi Biju,

On 01/10/19 12:09 PM, Biju Das wrote:
> Hello Kishon,
> 
> Are you happy with this patch? Please let me know.
> 
> https://patchwork.kernel.org/patch/10946601/


Can you resend the patch with the updated tags please?

Thanks
Kishon
> 
> 
> Regards,
> Biju
> 
>> Subject: RE: [PATCH v2] phy: renesas: phy-rcar-gen2: Fix the array off by one
>> warning
>>
>> Hi Biju-san,
>>
>>> From: Biju Das, Sent: Thursday, May 16, 2019 10:22 PM
>>>
>>> Fix the below smatch warning by adding variable check rather than the
>>> hardcoded value.
>>> warn: array off by one? 'data->select_value[channel_num]'
>>>
>>> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>>> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
>>> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>>
>> Thank you for the patch!
>>
>> Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
>>
>> Best regards,
>> Yoshihiro Shimoda
> 

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

* RE: [PATCH v2] phy: renesas: phy-rcar-gen2: Fix the array off by one warning
  2019-10-09 12:54     ` Kishon Vijay Abraham I
@ 2019-10-09 13:01       ` Biju Das
  0 siblings, 0 replies; 7+ messages in thread
From: Biju Das @ 2019-10-09 13:01 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Simon Horman, Wolfram Sang, Simon Horman, Geert Uytterhoeven,
	Chris Paterson, Fabrizio Castro, linux-renesas-soc,
	Yoshihiro Shimoda

Hi Kishon,

Thanks for the feedback

> -----Original Message-----
> From: Kishon Vijay Abraham I <kishon@ti.com>
> Sent: Wednesday, October 9, 2019 1:55 PM
> To: Biju Das <biju.das@bp.renesas.com>
> Cc: Simon Horman <horms+renesas@verge.net.au>; Wolfram Sang
> <wsa+renesas@sang-engineering.com>; Simon Horman
> <horms@verge.net.au>; Geert Uytterhoeven <geert+renesas@glider.be>;
> Chris Paterson <Chris.Paterson2@renesas.com>; Fabrizio Castro
> <fabrizio.castro@bp.renesas.com>; linux-renesas-soc@vger.kernel.org;
> Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Subject: Re: [PATCH v2] phy: renesas: phy-rcar-gen2: Fix the array off by one
> warning
> 
> Hi Biju,
> 
> On 01/10/19 12:09 PM, Biju Das wrote:
> > Hello Kishon,
> >
> > Are you happy with this patch? Please let me know.
> >
> > https://patchwork.kernel.org/patch/10946601/
> 
> 
> Can you resend the patch with the updated tags please?
> 

Yes. Will do

Regards,
Biju

> >
> >
> > Regards,
> > Biju
> >
> >> Subject: RE: [PATCH v2] phy: renesas: phy-rcar-gen2: Fix the array
> >> off by one warning
> >>
> >> Hi Biju-san,
> >>
> >>> From: Biju Das, Sent: Thursday, May 16, 2019 10:22 PM
> >>>
> >>> Fix the below smatch warning by adding variable check rather than
> >>> the hardcoded value.
> >>> warn: array off by one? 'data->select_value[channel_num]'
> >>>
> >>> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> >>> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> >>> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> >>
> >> Thank you for the patch!
> >>
> >> Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> >>
> >> Best regards,
> >> Yoshihiro Shimoda
> >

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

end of thread, other threads:[~2019-10-09 13:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-16 13:22 [PATCH v2] phy: renesas: phy-rcar-gen2: Fix the array off by one warning Biju Das
2019-05-16 13:51 ` Wolfram Sang
2019-05-17 13:25 ` Ulrich Hecht
2019-05-21  7:03 ` Yoshihiro Shimoda
2019-10-01  6:39   ` Biju Das
2019-10-09 12:54     ` Kishon Vijay Abraham I
2019-10-09 13:01       ` Biju Das

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).