netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Krzysztof Hałasa" <khalasa@piap.pl>
To: Kriish Sharma <kriish.sharma2006@gmail.com>
Cc: khc@pm.waw.pl,  andrew+netdev@lunn.ch,  davem@davemloft.net,
	edumazet@google.com,  kuba@kernel.org,  pabeni@redhat.com,
	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: Fri, 03 Oct 2025 08:34:01 +0200	[thread overview]
Message-ID: <m3o6qotrxi.fsf@t19.piap.pl> (raw)
In-Reply-To: <20251002180541.1375151-1-kriish.sharma2006@gmail.com> (Kriish Sharma's message of "Thu, 2 Oct 2025 18:05:41 +0000")

Hi Kriish,

Kriish Sharma <kriish.sharma2006@gmail.com> writes:

> 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));
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It appears proto_name(pid) never returns NULL there. Despite actually
saying "return NULL", that's right :-)

Perhaps you should change it to return "LCP" by default instead, and
not only on PID_LCP? It should silence the compiler.

This ppp_cp_event() is called in a few places:
- ppp_cp_parse_cr()
- ppp_rx()
- ppp_timer() (with a known protocol, though)
- and others, with PID_LCP.

Now, before printing proto_name(pid), ppp_cp_event() does
proto = get_proto(pid), and dereferences it :-)

The pid seems to always come from ppp_rx(). Fortunately it's checked
at start, and it case of an unknown proto it goes straight to rx_error.
-- 
Krzysztof "Chris" Hałasa

Sieć Badawcza Łukasiewicz
Przemysłowy Instytut Automatyki i Pomiarów PIAP
Al. Jerozolimskie 202, 02-486 Warszawa

  parent reply	other threads:[~2025-10-03  6:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-02 18:05 [PATCH] drivers/net/wan/hdlc_ppp: fix potential null pointer in ppp_cp_event logging Kriish Sharma
2025-10-02 18:16 ` Dimitri Daskalakis
2025-10-02 18:31   ` Kriish Sharma
2025-10-03  6:34 ` Krzysztof Hałasa [this message]
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=m3o6qotrxi.fsf@t19.piap.pl \
    --to=khalasa@piap.pl \
    --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;
as well as URLs for NNTP newsgroup(s).