MPTCP Linux Development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter at oracle.com>
To: mptcp at lists.01.org
Subject: [MPTCP] Re: [MPTCP][PATCH v2 net] mptcp: fix static checker warnings in mptcp_pm_add_timer
Date: Mon, 09 Nov 2020 14:26:23 +0300	[thread overview]
Message-ID: <20201109112623.GM18329@kadam> (raw)
In-Reply-To: 6bedbef3c2cb93ab9f3d15e78bd023043a83acbe.1604918403.git.geliangtang@gmail.com

[-- Attachment #1: Type: text/plain, Size: 2421 bytes --]

On Mon, Nov 09, 2020 at 06:44:09PM +0800, Geliang Tang wrote:
> Fix the following Smatch complaint:
> 
>      net/mptcp/pm_netlink.c:213 mptcp_pm_add_timer()
>      warn: variable dereferenced before check 'msk' (see line 208)
> 
>  net/mptcp/pm_netlink.c
>     207          struct mptcp_sock *msk = entry->sock;
>     208          struct sock *sk = (struct sock *)msk;
>     209          struct net *net = sock_net(sk);
>                                            ^^
>  "msk" dereferenced here.
> 
>     210
>     211          pr_debug("msk=%p", msk);
>     212
>     213          if (!msk)
>                     ^^^^
>  Too late.
> 
>     214                  return;
>     215
> 
> Fixes: 93f323b9cccc ("mptcp: add a new sysctl add_addr_timeout")
> Reported-by: Dan Carpenter <dan.carpenter(a)oracle.com>
> Signed-off-by: Geliang Tang <geliangtang(a)gmail.com>
> ---
>  v2:
>  - fix mptcp_pm_alloc_anno_list too

This is no required.

> ---
>  net/mptcp/pm_netlink.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index 6180a8b39a3f..59678e59ff46 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
> @@ -206,7 +206,6 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
>  	struct mptcp_pm_add_entry *entry = from_timer(entry, timer, add_timer);
>  	struct mptcp_sock *msk = entry->sock;
>  	struct sock *sk = (struct sock *)msk;
> -	struct net *net = sock_net(sk);
>  
>  	pr_debug("msk=%p", msk);
>  
> @@ -235,7 +234,7 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
>  
>  	if (entry->retrans_times < ADD_ADDR_RETRANS_MAX)
>  		sk_reset_timer(sk, timer,
> -			       jiffies + mptcp_get_add_addr_timeout(net));
> +			       jiffies + mptcp_get_add_addr_timeout(sock_net(sk)));
>  
>  	spin_unlock_bh(&msk->pm.lock);
>  
> @@ -267,7 +266,6 @@ static bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk,


1)  "msk" is never NULL when we call this function.

>  {
>  	struct mptcp_pm_add_entry *add_entry = NULL;
>  	struct sock *sk = (struct sock *)msk;
> -	struct net *net = sock_net(sk);
>  
>  	if (lookup_anno_list_by_saddr(msk, &entry->addr))
                                      ^^^
2) If it were then this would Oops.

This change is nice, as a clean up but it's not required as a fix.

regards,
dan carpenter

                 reply	other threads:[~2020-11-09 11:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20201109112623.GM18329@kadam \
    --to=mptcp@lists.linux.dev \
    /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