mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dimitri Daskalakis <dimitri.daskalakis1@gmail.com>
To: Kriish Sharma <kriish.sharma2006@gmail.com>,
	khc@pm.waw.pl, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers/net/wan/hdlc_ppp: fix potential null pointer in ppp_cp_event logging
Date: Thu, 2 Oct 2025 11:16:13 -0700	[thread overview]
Message-ID: <34901d4b-0fa9-4a86-b8b1-9c9dc5ed0e2e@gmail.com> (raw)
In-Reply-To: <20251002180541.1375151-1-kriish.sharma2006@gmail.com>

On 10/2/25 11:05 AM, Kriish Sharma wrote:

> Fixes warnings observed during compilation with -Wformat-overflow:
>
> 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));
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Introduce local variable `pname` and fallback to "unknown" if proto_name(pid)
> returns NULL.
>
> Fixes: 262858079afd ("Add linux-next specific files for 20250926")
> Signed-off-by: Kriish Sharma <kriish.sharma2006@gmail.com>
> ---
>  drivers/net/wan/hdlc_ppp.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c
> index 7496a2e9a282..f3b3fa8d46fd 100644
> --- a/drivers/net/wan/hdlc_ppp.c
> +++ b/drivers/net/wan/hdlc_ppp.c
> @@ -339,7 +339,9 @@ static void ppp_cp_event(struct net_device *dev, u16 pid, u16 event, u8 code,
>  		ppp_tx_cp(dev, pid, CP_CODE_REJ, ++ppp->seq, len, data);
>  
>  	if (old_state != OPENED && proto->state == OPENED) {
> -		netdev_info(dev, "%s up\n", proto_name(pid));
> +		const char *pname = proto_name(pid);
> +
> +		netdev_info(dev, "%s up\n", pname ? pname : "unknown");
>  		if (pid == PID_LCP) {
>  			netif_dormant_off(dev);
>  			ppp_cp_event(dev, PID_IPCP, START, 0, 0, 0, NULL);
> @@ -350,7 +352,9 @@ static void ppp_cp_event(struct net_device *dev, u16 pid, u16 event, u8 code,
>  		}
>  	}
>  	if (old_state == OPENED && proto->state != OPENED) {
> -		netdev_info(dev, "%s down\n", proto_name(pid));
> +		const char *pname = proto_name(pid);
> +
> +		netdev_info(dev, "%s down\n", pname ? pname : "unknown");
>  		if (pid == PID_LCP) {
>  			netif_dormant_on(dev);
>  			ppp_cp_event(dev, PID_IPCP, STOP, 0, 0, 0, NULL);
Would it be better to return "unknown" in proto_name()'s default case?

  reply	other threads:[~2025-10-02 18:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-02 18:05 Kriish Sharma
2025-10-02 18:16 ` Dimitri Daskalakis [this message]
2025-10-02 18:31   ` Kriish Sharma
2025-10-03  6:34 ` Krzysztof Hałasa
2025-10-03  6:43   ` Kriish Sharma
2025-10-07  8:41     ` Paolo Abeni
2025-10-07  9:28       ` Krzysztof Hałasa
2025-10-07 10:46         ` Paolo Abeni
2025-10-07 11:38           ` Krzysztof Hałasa
2025-10-03  8:33 ` Simon Horman
2025-10-03  9:02   ` Kriish Sharma
2025-10-03  9:40     ` Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34901d4b-0fa9-4a86-b8b1-9c9dc5ed0e2e@gmail.com \
    --to=dimitri.daskalakis1@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=khc@pm.waw.pl \
    --cc=kriish.sharma2006@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome