Linux CAN drivers development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: mailhol.vincent@wanadoo.fr
Cc: linux-can@vger.kernel.org
Subject: [bug report] can: etas_es58x: add core support for ETAS ES58X CAN USB interfaces
Date: Tue, 1 Feb 2022 17:03:51 +0300	[thread overview]
Message-ID: <20220201140351.GA2548@kili> (raw)

Hello Vincent Mailhol,

The patch 8537257874e9: "can: etas_es58x: add core support for ETAS
ES58X CAN USB interfaces" from Apr 10, 2021, leads to the following
Smatch static checker warning:

drivers/net/can/usb/etas_es58x/es58x_core.c:1818 es58x_open()
warn: inconsistent refcounting 'es58x_dev->opened_channel_cnt.counter':
  inc on: 1793
  dec on: 1818

drivers/net/can/usb/etas_es58x/es58x_core.c
    1785 static int es58x_open(struct net_device *netdev)
    1786 {
    1787         struct es58x_device *es58x_dev = es58x_priv(netdev)->es58x_dev;
    1788         int ret;
    1789 
    1790         if (atomic_inc_return(&es58x_dev->opened_channel_cnt) == 1) {
    1791                 ret = es58x_alloc_rx_urbs(es58x_dev);
    1792                 if (ret)
    1793                         return ret;
                                 ^^^^^^^^^^^
This error path should decrement &es58x_dev->opened_channel_cnt back to
zero?

    1794 
    1795                 ret = es58x_set_realtime_diff_ns(es58x_dev);
    1796                 if (ret)
    1797                         goto free_urbs;
    1798         }
    1799 
    1800         ret = open_candev(netdev);
    1801         if (ret)
    1802                 goto free_urbs;
    1803 
    1804         ret = es58x_dev->ops->enable_channel(es58x_priv(netdev));
    1805         if (ret)
    1806                 goto free_urbs;
    1807 
    1808         netif_start_queue(netdev);
    1809 
    1810         return ret;
    1811 
    1812  free_urbs:
    1813         if (atomic_dec_and_test(&es58x_dev->opened_channel_cnt))
    1814                 es58x_free_urbs(es58x_dev);
    1815         netdev_err(netdev, "%s: Could not open the network device: %pe\n",
    1816                    __func__, ERR_PTR(ret));
    1817 
--> 1818         return ret;
    1819 }

regards,
dan carpenter

                 reply	other threads:[~2022-02-01 14:04 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=20220201140351.GA2548@kili \
    --to=dan.carpenter@oracle.com \
    --cc=linux-can@vger.kernel.org \
    --cc=mailhol.vincent@wanadoo.fr \
    /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