* [PATCH] net: stmmac: fix a potential NULL pointer dereference
@ 2019-03-23 3:39 ` Kangjie Lu
0 siblings, 0 replies; 12+ messages in thread
From: Kangjie Lu @ 2019-03-23 3:39 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
David S. Miller, Maxime Coquelin, netdev, linux-stm32,
linux-arm-kernel, linux-kernel
In case of_device_get_match_data fails, the fix return -EINVAL
to avoid the NULL pointer dereference.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index 3256e5cbad27..344ead5949b1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -485,6 +485,8 @@ static int dwc_eth_dwmac_remove(struct platform_device *pdev)
int err;
data = of_device_get_match_data(&pdev->dev);
+ if (!data)
+ return -EINVAL;
err = stmmac_dvr_remove(&pdev->dev);
if (err < 0)
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH] net: stmmac: fix a potential NULL pointer dereference
@ 2019-03-23 3:39 ` Kangjie Lu
0 siblings, 0 replies; 12+ messages in thread
From: Kangjie Lu @ 2019-03-23 3:39 UTC (permalink / raw)
To: kjlu
Cc: Alexandre Torgue, netdev, linux-kernel, linux-stm32, Jose Abreu,
Maxime Coquelin, pakki001, Giuseppe Cavallaro, David S. Miller,
linux-arm-kernel
In case of_device_get_match_data fails, the fix return -EINVAL
to avoid the NULL pointer dereference.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index 3256e5cbad27..344ead5949b1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -485,6 +485,8 @@ static int dwc_eth_dwmac_remove(struct platform_device *pdev)
int err;
data = of_device_get_match_data(&pdev->dev);
+ if (!data)
+ return -EINVAL;
err = stmmac_dvr_remove(&pdev->dev);
if (err < 0)
--
2.17.1
_______________________________________________
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] 12+ messages in thread
* Re: [PATCH] net: stmmac: fix a potential NULL pointer dereference
2019-03-23 3:39 ` Kangjie Lu
@ 2019-03-26 0:15 ` David Miller
-1 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2019-03-26 0:15 UTC (permalink / raw)
To: kjlu
Cc: pakki001, peppe.cavallaro, alexandre.torgue, joabreu,
mcoquelin.stm32, netdev, linux-stm32, linux-arm-kernel,
linux-kernel
From: Kangjie Lu <kjlu@umn.edu>
Date: Fri, 22 Mar 2019 22:39:42 -0500
> @@ -485,6 +485,8 @@ static int dwc_eth_dwmac_remove(struct platform_device *pdev)
> int err;
>
> data = of_device_get_match_data(&pdev->dev);
> + if (!data)
> + return -EINVAL;
>
> err = stmmac_dvr_remove(&pdev->dev);
> if (err < 0)
> --
> 2.17.1
>
Please show me the entry in dwc_eth_dwmac_driver that has a NULL of_match_table
field.
Otherwise I'm not applying this.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] net: stmmac: fix a potential NULL pointer dereference
@ 2019-03-26 0:15 ` David Miller
0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2019-03-26 0:15 UTC (permalink / raw)
To: kjlu
Cc: alexandre.torgue, netdev, linux-kernel, joabreu, mcoquelin.stm32,
pakki001, peppe.cavallaro, linux-stm32, linux-arm-kernel
From: Kangjie Lu <kjlu@umn.edu>
Date: Fri, 22 Mar 2019 22:39:42 -0500
> @@ -485,6 +485,8 @@ static int dwc_eth_dwmac_remove(struct platform_device *pdev)
> int err;
>
> data = of_device_get_match_data(&pdev->dev);
> + if (!data)
> + return -EINVAL;
>
> err = stmmac_dvr_remove(&pdev->dev);
> if (err < 0)
> --
> 2.17.1
>
Please show me the entry in dwc_eth_dwmac_driver that has a NULL of_match_table
field.
Otherwise I'm not applying this.
_______________________________________________
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] 12+ messages in thread
* Re: [PATCH] net: stmmac: fix a potential NULL pointer dereference
[not found] ` <0f518f7a-ff1f-b8d9-8468-a1f7648ada46@codeaurora.org>
@ 2019-03-26 19:50 ` David Miller
0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2019-03-26 19:50 UTC (permalink / raw)
To: mojha
Cc: kjlu, alexandre.torgue, netdev, linux-kernel, linux-stm32,
joabreu, mcoquelin.stm32, pakki001, peppe.cavallaro,
linux-arm-kernel
From: Mukesh Ojha <mojha@codeaurora.org>
Date: Tue, 26 Mar 2019 15:27:03 +0530
>
> On 3/23/2019 9:09 AM, Kangjie Lu wrote:
>> In case of_device_get_match_data fails, the fix return -EINVAL
>> to avoid the NULL pointer dereference.
>>
>> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
>> ---
>> drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
>> b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
>> index 3256e5cbad27..344ead5949b1 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
>> @@ -485,6 +485,8 @@ static int dwc_eth_dwmac_remove(struct
>> platform_device *pdev)
>> int err;
>> data = of_device_get_match_data(&pdev->dev);
>> + if (!data)
>> + return -EINVAL;
>
> Although, it is false alarm for this driver as of_match_table is not
> NULL, but it would be good to add the check.
I disagree.
This is adding a check just for the sake of adding the check and
shutting up a static analysis tool.
Now, if the tool looked at the table entries being fed into this
function, and found such a posibility then we would fix the bug
and still not add the check.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] net: stmmac: fix a potential NULL pointer dereference
@ 2019-03-26 19:50 ` David Miller
0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2019-03-26 19:50 UTC (permalink / raw)
To: mojha
Cc: alexandre.torgue, netdev, kjlu, linux-kernel, joabreu,
mcoquelin.stm32, pakki001, peppe.cavallaro, linux-stm32,
linux-arm-kernel
From: Mukesh Ojha <mojha@codeaurora.org>
Date: Tue, 26 Mar 2019 15:27:03 +0530
>
> On 3/23/2019 9:09 AM, Kangjie Lu wrote:
>> In case of_device_get_match_data fails, the fix return -EINVAL
>> to avoid the NULL pointer dereference.
>>
>> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
>> ---
>> drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
>> b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
>> index 3256e5cbad27..344ead5949b1 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
>> @@ -485,6 +485,8 @@ static int dwc_eth_dwmac_remove(struct
>> platform_device *pdev)
>> int err;
>> data = of_device_get_match_data(&pdev->dev);
>> + if (!data)
>> + return -EINVAL;
>
> Although, it is false alarm for this driver as of_match_table is not
> NULL, but it would be good to add the check.
I disagree.
This is adding a check just for the sake of adding the check and
shutting up a static analysis tool.
Now, if the tool looked at the table entries being fed into this
function, and found such a posibility then we would fix the bug
and still not add the check.
_______________________________________________
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] 12+ messages in thread
* Re: [PATCH] net: stmmac: fix a potential NULL pointer dereference
2019-03-12 7:32 ` Kangjie Lu
@ 2019-03-27 13:42 ` Mukesh Ojha
-1 siblings, 0 replies; 12+ messages in thread
From: Mukesh Ojha @ 2019-03-27 13:42 UTC (permalink / raw)
To: Kangjie Lu
Cc: pakki001, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
David S. Miller, Maxime Coquelin, netdev, linux-stm32,
linux-arm-kernel, linux-kernel
On 3/12/2019 1:02 PM, Kangjie Lu wrote:
> In case of_device_get_match_data fails, the fix return -ENOMEM
s/-ENOMEM/-EINVAL
Otherwise looks good to me.
Make the above correction.
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
-Mukesh
> to avoid the NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> index 3256e5cbad27..344ead5949b1 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> @@ -485,6 +485,8 @@ static int dwc_eth_dwmac_remove(struct platform_device *pdev)
> int err;
>
> data = of_device_get_match_data(&pdev->dev);
> + if (!data)
> + return -EINVAL;
>
> err = stmmac_dvr_remove(&pdev->dev);
> if (err < 0)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] net: stmmac: fix a potential NULL pointer dereference
@ 2019-03-27 13:42 ` Mukesh Ojha
0 siblings, 0 replies; 12+ messages in thread
From: Mukesh Ojha @ 2019-03-27 13:42 UTC (permalink / raw)
To: Kangjie Lu
Cc: Alexandre Torgue, netdev, linux-kernel, linux-stm32, Jose Abreu,
Maxime Coquelin, pakki001, Giuseppe Cavallaro, David S. Miller,
linux-arm-kernel
On 3/12/2019 1:02 PM, Kangjie Lu wrote:
> In case of_device_get_match_data fails, the fix return -ENOMEM
s/-ENOMEM/-EINVAL
Otherwise looks good to me.
Make the above correction.
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
-Mukesh
> to avoid the NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> index 3256e5cbad27..344ead5949b1 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> @@ -485,6 +485,8 @@ static int dwc_eth_dwmac_remove(struct platform_device *pdev)
> int err;
>
> data = of_device_get_match_data(&pdev->dev);
> + if (!data)
> + return -EINVAL;
>
> err = stmmac_dvr_remove(&pdev->dev);
> if (err < 0)
_______________________________________________
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] 12+ messages in thread
* Re: [PATCH] net: stmmac: fix a potential NULL pointer dereference
2019-03-12 7:32 ` Kangjie Lu
@ 2019-03-12 8:28 ` Chen-Yu Tsai
-1 siblings, 0 replies; 12+ messages in thread
From: Chen-Yu Tsai @ 2019-03-12 8:28 UTC (permalink / raw)
To: Kangjie Lu
Cc: Alexandre Torgue, netdev, linux-kernel, linux-stm32, Jose Abreu,
Maxime Coquelin, pakki001, Giuseppe Cavallaro, David S. Miller,
linux-arm-kernel
On Tue, Mar 12, 2019 at 3:32 PM Kangjie Lu <kjlu@umn.edu> wrote:
>
> In case of_device_get_match_data fails, the fix return -ENOMEM
> to avoid the NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> index 3256e5cbad27..344ead5949b1 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> @@ -485,6 +485,8 @@ static int dwc_eth_dwmac_remove(struct platform_device *pdev)
> int err;
>
> data = of_device_get_match_data(&pdev->dev);
> + if (!data)
> + return -EINVAL;
You say -ENOMEM in the commit message, but -EINVAL here.
Also, all compatible strings within this driver have data attached
to them. The only possible case for this to return NULL is if the
user is screwing around with the kernel, such as creating a platform
device matching the driver name. This is not the intended way to
use it, and IMHO the kernel has the right to blow up in the user's
face.
ChenYu
>
> err = stmmac_dvr_remove(&pdev->dev);
> if (err < 0)
> --
> 2.17.1
>
>
> _______________________________________________
> 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] 12+ messages in thread
* Re: [PATCH] net: stmmac: fix a potential NULL pointer dereference
@ 2019-03-12 8:28 ` Chen-Yu Tsai
0 siblings, 0 replies; 12+ messages in thread
From: Chen-Yu Tsai @ 2019-03-12 8:28 UTC (permalink / raw)
To: Kangjie Lu
Cc: Alexandre Torgue, netdev, linux-kernel, David S. Miller,
Jose Abreu, Maxime Coquelin, pakki001, Giuseppe Cavallaro,
linux-stm32, linux-arm-kernel
On Tue, Mar 12, 2019 at 3:32 PM Kangjie Lu <kjlu@umn.edu> wrote:
>
> In case of_device_get_match_data fails, the fix return -ENOMEM
> to avoid the NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> index 3256e5cbad27..344ead5949b1 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> @@ -485,6 +485,8 @@ static int dwc_eth_dwmac_remove(struct platform_device *pdev)
> int err;
>
> data = of_device_get_match_data(&pdev->dev);
> + if (!data)
> + return -EINVAL;
You say -ENOMEM in the commit message, but -EINVAL here.
Also, all compatible strings within this driver have data attached
to them. The only possible case for this to return NULL is if the
user is screwing around with the kernel, such as creating a platform
device matching the driver name. This is not the intended way to
use it, and IMHO the kernel has the right to blow up in the user's
face.
ChenYu
>
> err = stmmac_dvr_remove(&pdev->dev);
> if (err < 0)
> --
> 2.17.1
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
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] 12+ messages in thread
* [PATCH] net: stmmac: fix a potential NULL pointer dereference
@ 2019-03-12 7:32 ` Kangjie Lu
0 siblings, 0 replies; 12+ messages in thread
From: Kangjie Lu @ 2019-03-12 7:32 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
David S. Miller, Maxime Coquelin, netdev, linux-stm32,
linux-arm-kernel, linux-kernel
In case of_device_get_match_data fails, the fix return -ENOMEM
to avoid the NULL pointer dereference.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index 3256e5cbad27..344ead5949b1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -485,6 +485,8 @@ static int dwc_eth_dwmac_remove(struct platform_device *pdev)
int err;
data = of_device_get_match_data(&pdev->dev);
+ if (!data)
+ return -EINVAL;
err = stmmac_dvr_remove(&pdev->dev);
if (err < 0)
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH] net: stmmac: fix a potential NULL pointer dereference
@ 2019-03-12 7:32 ` Kangjie Lu
0 siblings, 0 replies; 12+ messages in thread
From: Kangjie Lu @ 2019-03-12 7:32 UTC (permalink / raw)
To: kjlu
Cc: Alexandre Torgue, netdev, linux-kernel, linux-stm32, Jose Abreu,
Maxime Coquelin, pakki001, Giuseppe Cavallaro, David S. Miller,
linux-arm-kernel
In case of_device_get_match_data fails, the fix return -ENOMEM
to avoid the NULL pointer dereference.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index 3256e5cbad27..344ead5949b1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -485,6 +485,8 @@ static int dwc_eth_dwmac_remove(struct platform_device *pdev)
int err;
data = of_device_get_match_data(&pdev->dev);
+ if (!data)
+ return -EINVAL;
err = stmmac_dvr_remove(&pdev->dev);
if (err < 0)
--
2.17.1
_______________________________________________
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] 12+ messages in thread
end of thread, other threads:[~2019-03-27 13:42 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-23 3:39 [PATCH] net: stmmac: fix a potential NULL pointer dereference Kangjie Lu
2019-03-23 3:39 ` Kangjie Lu
2019-03-26 0:15 ` David Miller
2019-03-26 0:15 ` David Miller
[not found] ` <0f518f7a-ff1f-b8d9-8468-a1f7648ada46@codeaurora.org>
2019-03-26 19:50 ` David Miller
2019-03-26 19:50 ` David Miller
-- strict thread matches above, loose matches on Subject: below --
2019-03-12 7:32 Kangjie Lu
2019-03-12 7:32 ` Kangjie Lu
2019-03-12 8:28 ` Chen-Yu Tsai
2019-03-12 8:28 ` Chen-Yu Tsai
2019-03-27 13:42 ` Mukesh Ojha
2019-03-27 13:42 ` Mukesh Ojha
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.