Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Suggested-by: Krzysztof Hałasa <khalasa@piap.pl>
Signed-off-by: Kriish Sharma <kriish.sharma2006@gmail.com>
Acked-by: Krzysztof Hałasa <khalasa@piap.pl>
Link: https://patch.msgid.link/20251013014319.1608706-1-kriish.sharma2006@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Kriish Sharma and committed by
Paolo Abeni
3dacc900 18a7e218

+1 -3
+1 -3
drivers/net/wan/hdlc_ppp.c
··· 126 126 static inline const char *proto_name(u16 pid) 127 127 { 128 128 switch (pid) { 129 - case PID_LCP: 130 - return "LCP"; 131 129 case PID_IPCP: 132 130 return "IPCP"; 133 131 case PID_IPV6CP: 134 132 return "IPV6CP"; 135 133 default: 136 - return NULL; 134 + return "LCP"; 137 135 } 138 136 } 139 137