Skip to contentSkip to conversation

hdlc_ppp: fix potential null pointer in ppp_cp_event logging

PATCH Applied Kriish Sharma 3 participants 3 messages Oct 13, 2025 – Oct 14, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 hdlc_ppp: fix potential null pointer in ppp_cp_event logging

drivers/net/wan/hdlc_ppp.c: In function ‘ppp_cp_event’:
drivers/net/wan/hdlc_ppp.c:353:17: warning: ‘%s’ directive argument is null [-Wformat-overflow=]

  353 |                 netdev_info(dev, "%s down\n", proto_name(pid));
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wan/hdlc_ppp.c:342:17: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  342 |                 netdev_info(dev, "%s up\n", proto_name(pid));
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Update proto_name() to return "LCP" by default instead of NULL. This change silences the compiler without changing existing behavior and removes the need for the local 'pname' variable in ppp_cp_event.

---
v3:
- Retarget patch to net-next (cleanup, not bugfix)
- Remove 'Fixes' tag
- Drop explicit PID_LCP case in proto_name() per Chris’s suggestion

v2: https://lore.kernel.org/all/[email protected]/
- Target the net tree with proper subject prefix "[PATCH net]"
- Update proto_name() to return "LCP" by default instead of NULL
- Remove local 'pname' variable in ppp_cp_event
- Add Suggested-by tag for Krzysztof Hałasa

v1: https://lore.kernel.org/all/[email protected]/

 drivers/net/wan/hdlc_ppp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/wan/hdlc_ppp.c +1 -3
index 7496a2e9a282..159295c4bd6d 100644
@@ -126,14 +126,12 @@ static inline struct proto *get_proto(struct net_device *dev, u16 pid)
 static inline const char *proto_name(u16 pid)
 {
 	switch (pid) {
-	case PID_LCP:
-		return "LCP";
 	case PID_IPCP:
 		return "IPCP";
 	case PID_IPV6CP:
 		return "IPV6CP";
 	default:
-		return NULL;
+		return "LCP";
 	}
 }
 
Signature · 1 line
2.34.1
Acked-by on v3 1/1
#1 lore raw
Quoted 6 lines · Kriish Sharma

Update proto_name() to return "LCP" by default instead of NULL. This change silences the compiler without changing existing behavior and removes the need for the local 'pname' variable in ppp_cp_event.

Thanks, and

Quoted 18 lines
drivers/net/wan/hdlc_ppp.c +1 -3
@@ -126,14 +126,12 @@ static inline struct proto *get_proto(struct net_device *dev, u16 pid)
 static inline const char *proto_name(u16 pid)
 {
        switch (pid) {
-       case PID_LCP:
-               return "LCP";
        case PID_IPCP:
                return "IPCP";
        case PID_IPV6CP:
                return "IPV6CP";
        default:
-               return NULL;
+               return "LCP";
        }
 }
 
Signature · 5 lines
Krzysztof "Chris" Hałasa

Sieć Badawcza Łukasiewicz
Przemysłowy Instytut Automatyki i Pomiarów PIAP
Al. Jerozolimskie 202, 02-486 Warszawa
#2 lore raw
In reply to Kriish Sharma
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 9 lines · On Mon, 13 Oct 2025 01:43:19 +0000 you wrote:

drivers/net/wan/hdlc_ppp.c: In function ‘ppp_cp_event’:
drivers/net/wan/hdlc_ppp.c:353:17: warning: ‘%s’ directive argument is null [-Wformat-overflow=]

  353 |                 netdev_info(dev, "%s down\n", proto_name(pid));
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wan/hdlc_ppp.c:342:17: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  342 |                 netdev_info(dev, "%s up\n", proto_name(pid));
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[...]

Here is the summary with links:
- [net-next,v3] hdlc_ppp: fix potential null pointer in ppp_cp_event logging

    https://git.kernel.org/netdev/net-next/c/3dacc900c00b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html