diff mbox series

[3/8] interconnect: imx: fix max_node_id

Message ID 20220601094156.3388454-4-peng.fan@oss.nxp.com
State New
Headers show
Series interconnect: support i.MX8MP | expand

Commit Message

Peng Fan (OSS) June 1, 2022, 9:41 a.m. UTC
From: Peng Fan <peng.fan@nxp.com>

max_node_id not equal to the ARRAY_SIZE of node array, need increase 1,
otherwise xlate will fail for the last entry.

Fixes: f0d8048525d7d("interconnect: Add imx core driver")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/interconnect/imx/imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Pinchart June 4, 2022, 12:14 a.m. UTC | #1
Hi Peng,

Thank you for the patch.

On Wed, Jun 01, 2022 at 05:41:51PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> max_node_id not equal to the ARRAY_SIZE of node array, need increase 1,
> otherwise xlate will fail for the last entry.
> 
> Fixes: f0d8048525d7d("interconnect: Add imx core driver")
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/interconnect/imx/imx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/interconnect/imx/imx.c b/drivers/interconnect/imx/imx.c
> index 249ca25d1d55..3c074933ed0c 100644
> --- a/drivers/interconnect/imx/imx.c
> +++ b/drivers/interconnect/imx/imx.c
> @@ -238,7 +238,7 @@ int imx_icc_register(struct platform_device *pdev,
>  	int ret;
>  
>  	/* icc_onecell_data is indexed by node_id, unlike nodes param */
> -	max_node_id = get_max_node_id(nodes, nodes_count);
> +	max_node_id = get_max_node_id(nodes, nodes_count) + 1;

I'd rename the max_node_id variable to num_nodes, as writing

	max_node_id = get_max_node_id(...) + 1;

looks weird.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  	data = devm_kzalloc(dev, struct_size(data, nodes, max_node_id),
>  			    GFP_KERNEL);
>  	if (!data)
Peng Fan June 13, 2022, 1:17 a.m. UTC | #2
> Subject: Re: [PATCH 3/8] interconnect: imx: fix max_node_id
> 
> Hi Peng,
> 
> Thank you for the patch.
> 
> On Wed, Jun 01, 2022 at 05:41:51PM +0800, Peng Fan (OSS) wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > max_node_id not equal to the ARRAY_SIZE of node array, need increase
> > 1, otherwise xlate will fail for the last entry.
> >
> > Fixes: f0d8048525d7d("interconnect: Add imx core driver")
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  drivers/interconnect/imx/imx.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/interconnect/imx/imx.c
> > b/drivers/interconnect/imx/imx.c index 249ca25d1d55..3c074933ed0c
> > 100644
> > --- a/drivers/interconnect/imx/imx.c
> > +++ b/drivers/interconnect/imx/imx.c
> > @@ -238,7 +238,7 @@ int imx_icc_register(struct platform_device *pdev,
> >  	int ret;
> >
> >  	/* icc_onecell_data is indexed by node_id, unlike nodes param */
> > -	max_node_id = get_max_node_id(nodes, nodes_count);
> > +	max_node_id = get_max_node_id(nodes, nodes_count) + 1;
> 
> I'd rename the max_node_id variable to num_nodes, as writing
> 
> 	max_node_id = get_max_node_id(...) + 1;
> 
> looks weird.

Thanks, will follow your suggestion in V2.

Thanks,
Peng.

> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> >  	data = devm_kzalloc(dev, struct_size(data, nodes, max_node_id),
> >  			    GFP_KERNEL);
> >  	if (!data)
> 
> --
> Regards,
> 
> Laurent Pinchart
diff mbox series

Patch

diff --git a/drivers/interconnect/imx/imx.c b/drivers/interconnect/imx/imx.c
index 249ca25d1d55..3c074933ed0c 100644
--- a/drivers/interconnect/imx/imx.c
+++ b/drivers/interconnect/imx/imx.c
@@ -238,7 +238,7 @@  int imx_icc_register(struct platform_device *pdev,
 	int ret;
 
 	/* icc_onecell_data is indexed by node_id, unlike nodes param */
-	max_node_id = get_max_node_id(nodes, nodes_count);
+	max_node_id = get_max_node_id(nodes, nodes_count) + 1;
 	data = devm_kzalloc(dev, struct_size(data, nodes, max_node_id),
 			    GFP_KERNEL);
 	if (!data)