All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: ubraun@linux.ibm.com
Cc: linux-s390@vger.kernel.org
Subject: Re: [bug report] net/smc: fix ethernet interface refcounting
Date: Mon, 2 Dec 2019 16:23:16 +0300	[thread overview]
Message-ID: <20191202132316.GA1787@kadam> (raw)
In-Reply-To: <20191202131233.2b4daujqmi27tecx@kili.mountain>

Oops...  I read the caller and it's fine.  My bad.

regards,
dan carpenter

On Mon, Dec 02, 2019 at 04:12:33PM +0300, Dan Carpenter wrote:
> Hello Ursula Braun,
> 
> The patch 98f3375505b8: "net/smc: fix ethernet interface refcounting"
> from Nov 6, 2019, leads to the following static checker warning:
> 
> 	net/smc/smc_pnet.c:379 smc_pnet_fill_entry()
> 	warn: 'pnetelem->ndev' held on error path.
> 
> net/smc/smc_pnet.c
>    329  static int smc_pnet_fill_entry(struct net *net,
>    330                                 struct smc_user_pnetentry *pnetelem,
>    331                                 struct nlattr *tb[])
>    332  {
>    333          char *string, *ibname;
>    334          int rc;
>    335  
>    336          memset(pnetelem, 0, sizeof(*pnetelem));
>    337          INIT_LIST_HEAD(&pnetelem->list);
>    338  
>    339          rc = -EINVAL;
>    340          if (!tb[SMC_PNETID_NAME])
>    341                  goto error;
>    342          string = (char *)nla_data(tb[SMC_PNETID_NAME]);
>    343          if (!smc_pnetid_valid(string, pnetelem->pnet_name))
>    344                  goto error;
>    345  
>    346          rc = -EINVAL;
>    347          if (tb[SMC_PNETID_ETHNAME]) {
>    348                  string = (char *)nla_data(tb[SMC_PNETID_ETHNAME]);
>    349                  pnetelem->ndev = dev_get_by_name(net, string);
>                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> dev_hold().
> 
>    350                  if (!pnetelem->ndev)
>    351                          goto error;
>    352          }
>    353  
>    354          /* if this is not the initial namespace, stop here */
>    355          if (net != &init_net)
>    356                  return 0;
>    357  
>    358          rc = -EINVAL;
>    359          if (tb[SMC_PNETID_IBNAME]) {
>    360                  ibname = (char *)nla_data(tb[SMC_PNETID_IBNAME]);
>    361                  ibname = strim(ibname);
>    362                  pnetelem->smcibdev = smc_pnet_find_ib(ibname);
>    363                  pnetelem->smcd_dev = smc_pnet_find_smcd(ibname);
>    364                  if (!pnetelem->smcibdev && !pnetelem->smcd_dev)
>    365                          goto error;
>                                 ^^^^^^^^^^
> Smatch thinks these require dev_put()
> 
>    366                  if (pnetelem->smcibdev) {
>    367                          if (!tb[SMC_PNETID_IBPORT])
>    368                                  goto error;
>    369                          pnetelem->ib_port = nla_get_u8(tb[SMC_PNETID_IBPORT]);
>    370                          if (pnetelem->ib_port < 1 ||
>    371                              pnetelem->ib_port > SMC_MAX_PORTS)
>    372                                  goto error;
>                                         ^^^^^^^^^^
>    373                  }
>    374          }
>    375  
>    376          return 0;
>    377  
>    378  error:
> 
> So maybe this should be:
> 
> 	if (pnetelem->ndev && tb[SMC_PNETID_ETHNAME])
> 		dev_put(pnetelem->ndev);
> 
>    379          return rc;
>    380  }
> 
> regards,
> dan carpenter

      reply	other threads:[~2019-12-02 13:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-02 13:12 [bug report] net/smc: fix ethernet interface refcounting Dan Carpenter
2019-12-02 13:23 ` 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=20191202132316.GA1787@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=ubraun@linux.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.