From: Dan Carpenter <error27@gmail.com>
To: Li Qiong <liqiong@nfschina.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org, Yu Zhe <yuzhe@nfschina.com>
Subject: Re: [PATCH] net/atm/mpc: Fix dereference NULL pointer in mpc_send_packet()
Date: Thu, 23 Feb 2023 10:59:05 +0300 [thread overview]
Message-ID: <Y/ccya+o7zBqMyhJ@kadam> (raw)
In-Reply-To: <20230223065446.24173-1-liqiong@nfschina.com>
On Thu, Feb 23, 2023 at 02:54:46PM +0800, Li Qiong wrote:
> The 'non_ip' statement need do 'mpc' pointer dereference,
> so return '-ENODEV' if 'mpc' is NULL.
>
> Signed-off-by: Li Qiong <liqiong@nfschina.com>
> ---
> net/atm/mpc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/atm/mpc.c b/net/atm/mpc.c
> index 033871e718a3..1cd6610b8a12 100644
> --- a/net/atm/mpc.c
> +++ b/net/atm/mpc.c
> @@ -577,7 +577,7 @@ static netdev_tx_t mpc_send_packet(struct sk_buff *skb,
> mpc = find_mpc_by_lec(dev); /* this should NEVER fail */
> if (mpc == NULL) {
> pr_info("(%s) no MPC found\n", dev->name);
> - goto non_ip;
> + return -ENODEV;
> }
The comment says that find_mpc_by_lec() can't fail. This business of
handling impossible situations is very complicated. Should this
free the skb before returning? Eventually static checkers will detect
that.
Generally the rule is that we don't have checks for impossible
conditions. That would trigger a warning for certain static checkers
but it would be a false positive. Otherwise we need to add a whole
bunch of code to silence all warnings about handling an impossible
situation correctly.
regards,
dan carpenter
prev parent reply other threads:[~2023-02-23 7:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-23 6:54 [PATCH] net/atm/mpc: Fix dereference NULL pointer in mpc_send_packet() Li Qiong
2023-02-23 7:59 ` Dan Carpenter [this message]
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=Y/ccya+o7zBqMyhJ@kadam \
--to=error27@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liqiong@nfschina.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=yuzhe@nfschina.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