* [PATCH] soc: ti: pruss: fix return check for of_device_get_match_data()
@ 2020-11-10 1:33 Luo Meng
2020-11-10 8:28 ` Grzegorz Jaszczyk
0 siblings, 1 reply; 4+ messages in thread
From: Luo Meng @ 2020-11-10 1:33 UTC (permalink / raw)
To: ssantosh, rogerq, grzegorz.jaszczyk, s-anna, linux-arm-kernel, luomeng12
of_device_get_match_data() maybe return NULL pointer which cannot
be checked with IS_ERR.
Fixes: ba59c9b43c86 ("soc: ti: pruss: support CORECLK_MUX and IEPCLK_MUX")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Luo Meng <luomeng12@huawei.com>
---
drivers/soc/ti/pruss.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/soc/ti/pruss.c b/drivers/soc/ti/pruss.c
index cc0b4ad7a3d3..582f48051c30 100644
--- a/drivers/soc/ti/pruss.c
+++ b/drivers/soc/ti/pruss.c
@@ -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;
}
--
2.25.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] soc: ti: pruss: fix return check for of_device_get_match_data()
2020-11-10 1:33 [PATCH] soc: ti: pruss: fix return check for of_device_get_match_data() Luo Meng
@ 2020-11-10 8:28 ` Grzegorz Jaszczyk
2020-11-10 9:54 ` Lee Jones
0 siblings, 1 reply; 4+ messages in thread
From: Grzegorz Jaszczyk @ 2020-11-10 8:28 UTC (permalink / raw)
To: Luo Meng, Anna, Suman
Cc: Roger Quadros, Lee Jones, linux-arm-kernel, Santosh Shilimkar
Hi
On Tue, 10 Nov 2020 at 02:31, Luo Meng <luomeng12@huawei.com> wrote:
>
> of_device_get_match_data() maybe return NULL pointer which cannot
> be checked with IS_ERR.
>
> Fixes: ba59c9b43c86 ("soc: ti: pruss: support CORECLK_MUX and IEPCLK_MUX")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Luo Meng <luomeng12@huawei.com>
> ---
> drivers/soc/ti/pruss.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/soc/ti/pruss.c b/drivers/soc/ti/pruss.c
> index cc0b4ad7a3d3..582f48051c30 100644
> --- a/drivers/soc/ti/pruss.c
> +++ b/drivers/soc/ti/pruss.c
> @@ -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) {
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/20201026144943.30821-1-grzegorz.jaszczyk@linaro.org/
Thank you,
Grzegorz
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] soc: ti: pruss: fix return check for of_device_get_match_data()
2020-11-10 8:28 ` Grzegorz Jaszczyk
@ 2020-11-10 9:54 ` Lee Jones
2020-11-10 20:41 ` Suman Anna
0 siblings, 1 reply; 4+ messages in thread
From: Lee Jones @ 2020-11-10 9:54 UTC (permalink / raw)
To: Grzegorz Jaszczyk
Cc: Luo Meng, Roger Quadros, linux-arm-kernel, Santosh Shilimkar
On Tue, 10 Nov 2020, Grzegorz Jaszczyk wrote:
> Hi
>
> On Tue, 10 Nov 2020 at 02:31, Luo Meng <luomeng12@huawei.com> wrote:
> >
> > of_device_get_match_data() maybe return NULL pointer which cannot
> > be checked with IS_ERR.
> >
> > Fixes: ba59c9b43c86 ("soc: ti: pruss: support CORECLK_MUX and IEPCLK_MUX")
> > Reported-by: Hulk Robot <hulkci@huawei.com>
> > Signed-off-by: Luo Meng <luomeng12@huawei.com>
> > ---
> > drivers/soc/ti/pruss.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/soc/ti/pruss.c b/drivers/soc/ti/pruss.c
> > index cc0b4ad7a3d3..582f48051c30 100644
> > --- a/drivers/soc/ti/pruss.c
> > +++ b/drivers/soc/ti/pruss.c
> > @@ -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;
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.
> > 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) {
>
> 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/20201026144943.30821-1-grzegorz.jaszczyk@linaro.org/
>
> Thank you,
> Grzegorz
--
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
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] soc: ti: pruss: fix return check for of_device_get_match_data()
2020-11-10 9:54 ` Lee Jones
@ 2020-11-10 20:41 ` Suman Anna
0 siblings, 0 replies; 4+ messages in thread
From: Suman Anna @ 2020-11-10 20:41 UTC (permalink / raw)
To: Lee Jones, Grzegorz Jaszczyk
Cc: Luo Meng, Roger Quadros, linux-arm-kernel, Santosh Shilimkar
Hi Luo,
On 11/10/20 3:54 AM, Lee Jones wrote:
> On Tue, 10 Nov 2020, Grzegorz Jaszczyk wrote:
>
>> Hi
>>
>> On Tue, 10 Nov 2020 at 02:31, Luo Meng <luomeng12@huawei.com> wrote:
>>>
>>> of_device_get_match_data() maybe return NULL pointer which cannot
>>> be checked with IS_ERR.
>>>
>>> Fixes: ba59c9b43c86 ("soc: ti: pruss: support CORECLK_MUX and IEPCLK_MUX")
>>> Reported-by: Hulk Robot <hulkci@huawei.com>
>>> Signed-off-by: Luo Meng <luomeng12@huawei.com>
>>> ---
>>> drivers/soc/ti/pruss.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/soc/ti/pruss.c b/drivers/soc/ti/pruss.c
>>> index cc0b4ad7a3d3..582f48051c30 100644
>>> --- a/drivers/soc/ti/pruss.c
>>> +++ b/drivers/soc/ti/pruss.c
>>> @@ -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;
>
> 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.
>
>>> 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) {
>>
>> 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/20201026144943.30821-1-grzegorz.jaszczyk@linaro.org/
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/20200915075732.100804-1-weiyongjun1@huawei.com/
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-11-10 20:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-10 1:33 [PATCH] soc: ti: pruss: fix return check for of_device_get_match_data() Luo Meng
2020-11-10 8:28 ` Grzegorz Jaszczyk
2020-11-10 9:54 ` Lee Jones
2020-11-10 20:41 ` Suman Anna
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.