diff mbox series

net: lan966x: check for ptp to be enabled in lan966x_ptp_deinit()

Message ID 20230106134830.333494-1-clement.leger@bootlin.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: lan966x: check for ptp to be enabled in lan966x_ptp_deinit() | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Clément Léger Jan. 6, 2023, 1:48 p.m. UTC
If ptp was not enabled due to missing IRQ for instance,
lan966x_ptp_deinit() will dereference NULL pointers.

Fixes: d096459494a8 ("net: lan966x: Add support for ptp clocks")
Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
 drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Horatiu Vultur Jan. 6, 2023, 8:21 p.m. UTC | #1
The 01/06/2023 14:48, Clément Léger wrote:

Hi Clement,

> 
> If ptp was not enabled due to missing IRQ for instance,
> lan966x_ptp_deinit() will dereference NULL pointers.
> 
> Fixes: d096459494a8 ("net: lan966x: Add support for ptp clocks")
> Signed-off-by: Clément Léger <clement.leger@bootlin.com>

You forgot to mark the patch to target the net tree.  But other
than that looks good.

Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>

> ---
>  drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c b/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c
> index f9ebfaafbebc..a8348437dd87 100644
> --- a/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c
> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c
> @@ -1073,6 +1073,9 @@ void lan966x_ptp_deinit(struct lan966x *lan966x)
>         struct lan966x_port *port;
>         int i;
> 
> +       if (!lan966x->ptp)
> +               return;
> +
>         for (i = 0; i < lan966x->num_phys_ports; i++) {
>                 port = lan966x->ports[i];
>                 if (!port)
> --
> 2.38.1
>
Clément Léger Jan. 6, 2023, 8:24 p.m. UTC | #2
Le 2023-01-06 21:21, Horatiu Vultur a écrit :
> The 01/06/2023 14:48, Clément Léger wrote:
> 
> Hi Clement,
> 
>> 
>> If ptp was not enabled due to missing IRQ for instance,
>> lan966x_ptp_deinit() will dereference NULL pointers.
>> 
>> Fixes: d096459494a8 ("net: lan966x: Add support for ptp clocks")
>> Signed-off-by: Clément Léger <clement.leger@bootlin.com>
> 
> You forgot to mark the patch to target the net tree.  But other
> than that looks good.

Hi Horatiu,

I'll resent a V2 to the net tree then. Thanks for reviewing.

Clément

> 
> Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> 
>> ---
>>  drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c | 3 +++
>>  1 file changed, 3 insertions(+)
>> 
>> diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c 
>> b/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c
>> index f9ebfaafbebc..a8348437dd87 100644
>> --- a/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c
>> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c
>> @@ -1073,6 +1073,9 @@ void lan966x_ptp_deinit(struct lan966x *lan966x)
>>         struct lan966x_port *port;
>>         int i;
>> 
>> +       if (!lan966x->ptp)
>> +               return;
>> +
>>         for (i = 0; i < lan966x->num_phys_ports; i++) {
>>                 port = lan966x->ports[i];
>>                 if (!port)
>> --
>> 2.38.1
>>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c b/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c
index f9ebfaafbebc..a8348437dd87 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c
@@ -1073,6 +1073,9 @@  void lan966x_ptp_deinit(struct lan966x *lan966x)
 	struct lan966x_port *port;
 	int i;
 
+	if (!lan966x->ptp)
+		return;
+
 	for (i = 0; i < lan966x->num_phys_ports; i++) {
 		port = lan966x->ports[i];
 		if (!port)