All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: mailhol.vincent@wanadoo.fr
Cc: kernel-janitors@vger.kernel.org
Subject: [bug report] can: pch_can: do not report txerr and rxerr during bus-off
Date: Fri, 22 Jul 2022 13:07:02 +0300	[thread overview]
Message-ID: <Ytp2xv0jxwv7DBGU@kili> (raw)

Hello Vincent Mailhol,

The patch 3a5c7e4611dd: "can: pch_can: do not report txerr and rxerr
during bus-off" from Jul 19, 2022, leads to the following Smatch
static checker warning:

	drivers/net/can/pch_can.c:501 pch_can_error()
	error: uninitialized symbol 'errc'.

drivers/net/can/pch_can.c
    479 static void pch_can_error(struct net_device *ndev, u32 status)
    480 {
    481         struct sk_buff *skb;
    482         struct pch_can_priv *priv = netdev_priv(ndev);
    483         struct can_frame *cf;
    484         u32 errc, lec;
    485         struct net_device_stats *stats = &(priv->ndev->stats);
    486         enum can_state state = priv->can.state;
    487 
    488         skb = alloc_can_err_skb(ndev, &cf);
    489         if (!skb)
    490                 return;
    491 
    492         if (status & PCH_BUS_OFF) {
    493                 pch_can_set_tx_all(priv, 0);
    494                 pch_can_set_rx_all(priv, 0);
    495                 state = CAN_STATE_BUS_OFF;
    496                 cf->can_id |= CAN_ERR_BUSOFF;
    497                 priv->can.can_stats.bus_off++;
    498                 can_bus_off(ndev);
    499         } else {
    500                 cf->can_id |= CAN_ERR_CNT;
--> 501                 cf->data[6] = errc & PCH_TEC;

Not initialized at this point.

    502                 cf->data[7] = (errc & PCH_REC) >> 8;
    503         }
    504 
    505         errc = ioread32(&priv->regs->errc);
    506         /* Warning interrupt. */
    507         if (status & PCH_EWARN) {
    508                 state = CAN_STATE_ERROR_WARNING;
    509                 priv->can.can_stats.error_warning++;
    510                 cf->can_id |= CAN_ERR_CRTL;
    511                 if (((errc & PCH_REC) >> 8) > 96)
    512                         cf->data[1] |= CAN_ERR_CRTL_RX_WARNING;
    513                 if ((errc & PCH_TEC) > 96)
    514                         cf->data[1] |= CAN_ERR_CRTL_TX_WARNING;
    515                 netdev_dbg(ndev,
    516                         "%s -> Error Counter is more than 96.\n", __func__);
    517         }
    518         /* Error passive interrupt. */
    519         if (status & PCH_EPASSIV) {
    520                 priv->can.can_stats.error_passive++;
    521                 state = CAN_STATE_ERROR_PASSIVE;
    522                 cf->can_id |= CAN_ERR_CRTL;
    523                 if (errc & PCH_RP)
    524                         cf->data[1] |= CAN_ERR_CRTL_RX_PASSIVE;
    525                 if ((errc & PCH_TEC) > 127)
    526                         cf->data[1] |= CAN_ERR_CRTL_TX_PASSIVE;
    527                 netdev_dbg(ndev,
    528                         "%s -> CAN controller is ERROR PASSIVE .\n", __func__);
    529         }
    530 
    531         lec = status & PCH_LEC_ALL;
    532         switch (lec) {
    533         case PCH_STUF_ERR:
    534                 cf->data[2] |= CAN_ERR_PROT_STUFF;
    535                 priv->can.can_stats.bus_error++;
    536                 stats->rx_errors++;
    537                 break;
    538         case PCH_FORM_ERR:
    539                 cf->data[2] |= CAN_ERR_PROT_FORM;
    540                 priv->can.can_stats.bus_error++;
    541                 stats->rx_errors++;
    542                 break;
    543         case PCH_ACK_ERR:
    544                 cf->can_id |= CAN_ERR_ACK;
    545                 priv->can.can_stats.bus_error++;
    546                 stats->rx_errors++;
    547                 break;
    548         case PCH_BIT1_ERR:
    549         case PCH_BIT0_ERR:
    550                 cf->data[2] |= CAN_ERR_PROT_BIT;
    551                 priv->can.can_stats.bus_error++;
    552                 stats->rx_errors++;
    553                 break;
    554         case PCH_CRC_ERR:
    555                 cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
    556                 priv->can.can_stats.bus_error++;
    557                 stats->rx_errors++;
    558                 break;
    559         case PCH_LEC_ALL: /* Written by CPU. No error status */
    560                 break;
    561         }
    562 
    563         priv->can.state = state;
    564         netif_receive_skb(skb);
    565 }

regards,
dan carpenter

             reply	other threads:[~2022-07-22 10:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-22 10:07 Dan Carpenter [this message]
2022-07-22 10:29 ` [bug report] can: pch_can: do not report txerr and rxerr during bus-off Vincent MAILHOL

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=Ytp2xv0jxwv7DBGU@kili \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@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 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.