soc: ti: pruss: fix return check for of_device_get_match_data()
PATCH 1/1 soc: ti: pruss: fix return check for of_device_get_match_data()
of_device_get_match_data() maybe return NULL pointer which cannot be checked with IS_ERR.
--- drivers/soc/ti/pruss.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soc/ti/pruss.c +2 -2
@@ -126,7 +126,7 @@ static int pruss_clk_init(struct pruss *pruss, struct device_node *cfg_node)int ret =0 ; data =of_device_get_match_data (dev); -if (IS_ERR (data)) +if (!data)return -ENODEV ; clks_np =of_get_child_by_name (cfg_node,"clocks" );
@@ -175,7 +175,7 @@ static int pruss_probe(struct platform_device *pdev)const char *mem_names[PRUSS_MEM_MAX ] = {"dram0" ,"dram1" ,"shrdram2" }; data =of_device_get_match_data (&pdev->dev); -if (IS_ERR (data)) { +if (!data) {dev_err (dev,"missing private data\n" );return -ENODEV ; }
Signature · 7 lines
2.25.4 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi
Quoted 25 lines · Luo Meng
of_device_get_match_data()maybe return NULL pointer which cannot be checked withIS_ERR.Fixes ba59c9b43c86 ("soc: ti: pruss: support CORECLK_MUX and IEPCLK_MUX")Reported-by Hulk Robot <[email protected]>Signed-off-by Luo Meng <[email protected]>--- drivers/soc/ti/pruss.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/soc/ti/pruss.c +1
-1@@ -126,7 +126,7 @@ static int pruss_clk_init(struct pruss *pruss, struct device_node *cfg_node)int ret =0 ; data =of_device_get_match_data (dev); -if (IS_ERR (data)) +if (!data)return -ENODEV ; clks_np =of_get_child_by_name (cfg_node,"clocks" );
drivers/soc/ti/pruss.c static int pruss_probe(struct platform_device *pdev) · line 178
Quoted 5 lines
drivers/soc/ti/pruss.c +1
-1@@ -175,7 +175,7 @@ static int pruss_probe(struct platform_device *pdev)const char *mem_names[PRUSS_MEM_MAX ] = {"dram0" ,"dram1" ,"shrdram2" }; data =of_device_get_match_data (&pdev->dev); -if (IS_ERR (data)) { +if (!data) {
Thank you for your interest but with your patch the driver will not be functional anymore for all devices without match data (e.g. "ti,am3356-pruss") which is not what we want. The proper fix was already posted end of October:
https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email protected]/
Thank you,
Grzegorz
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 21 lines · Grzegorz Jaszczyk
Hi
Quoted 18 lines · Luo Meng
of_device_get_match_data()maybe return NULL pointer which cannot be checked withIS_ERR.Fixes ba59c9b43c86 ("soc: ti: pruss: support CORECLK_MUX and IEPCLK_MUX")Reported-by Hulk Robot <[email protected]>Signed-off-by Luo Meng <[email protected]>--- drivers/soc/ti/pruss.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/soc/ti/pruss.c +0
-0@@ -126,7 +126,7 @@ static int pruss_clk_init(struct pruss *pruss, struct device_node *cfg_node)int ret =0 ;
Quoted 4 lines
drivers/soc/ti/pruss.c static int pruss_clk_init(struct pruss *pruss, struct device_node *cfg_node) · line 130
Quoted 4 lines
drivers/soc/ti/pruss.c +1
-1data =of_device_get_match_data (dev); -if (IS_ERR (data)) +if (!data)return -ENODEV ;
Also this would miss any errors, leading to dereference issues.
I think what you meant was IS_ERR_OR_NULL(), but this would still be incorrect for the reasons Grzegorz mentions below.
Quoted 16 lines
drivers/soc/ti/pruss.c static int pruss_probe(struct platform_device *pdev) · line 178
Quoted 7 lines
drivers/soc/ti/pruss.c +1
-1clks_np =of_get_child_by_name (cfg_node,"clocks" );@@ -175,7 +175,7 @@ static int pruss_probe(struct platform_device *pdev)const char *mem_names[PRUSS_MEM_MAX ] = {"dram0" ,"dram1" ,"shrdram2" }; data =of_device_get_match_data (&pdev->dev); -if (IS_ERR (data)) { +if (!data) {Thank you for your interest but with your patch the driver will not be functional anymore for all devices without match data (e.g. "ti,am3356-pruss") which is not what we want. The proper fix was already posted end of October:
https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email protected]/Thank you,
Grzegorz
Signature · 9 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Luo,
Quoted 30 lines · Lee Jones
Quoted 21 lines · Grzegorz Jaszczyk
Hi
Quoted 18 lines · Luo Meng
of_device_get_match_data()maybe return NULL pointer which cannot be checked withIS_ERR.Fixes ba59c9b43c86 ("soc: ti: pruss: support CORECLK_MUX and IEPCLK_MUX")Reported-by Hulk Robot <[email protected]>Signed-off-by Luo Meng <[email protected]>--- drivers/soc/ti/pruss.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/soc/ti/pruss.c +0
-0@@ -126,7 +126,7 @@ static int pruss_clk_init(struct pruss *pruss, struct device_node *cfg_node)int ret =0 ;Quoted 4 lines
drivers/soc/ti/pruss.c static int pruss_clk_init(struct pruss *pruss, struct device_node *cfg_node) · line 130
Quoted 4 lines
drivers/soc/ti/pruss.c +1
-1data =of_device_get_match_data (dev); -if (IS_ERR (data)) +if (!data)return -ENODEV ;Also this would miss any errors, leading to dereference issues.
Quoted 16 lines
I think what you meant was
IS_ERR_OR_NULL(), but this would still be incorrect for the reasons Grzegorz mentions below.Quoted 13 lines
drivers/soc/ti/pruss.c static int pruss_probe(struct platform_device *pdev) · line 178
Quoted 7 lines
drivers/soc/ti/pruss.c +1
-1clks_np =of_get_child_by_name (cfg_node,"clocks" );@@ -175,7 +175,7 @@ static int pruss_probe(struct platform_device *pdev)const char *mem_names[PRUSS_MEM_MAX ] = {"dram0" ,"dram1" ,"shrdram2" }; data =of_device_get_match_data (&pdev->dev); -if (IS_ERR (data)) { +if (!data) {Thank you for your interest but with your patch the driver will not be functional anymore for all devices without match data (e.g. "ti,am3356-pruss") which is not what we want. The proper fix was already posted end of October:
https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email protected]/
Wei Yongjun from Huawei has posted an identical patch originally [1], which is what the above patch fixes. Please use Greg's updated patch instead.
regards
Suman
[1]
https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email protected]/
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel