All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] can: pch_can: do not report txerr and rxerr during bus-off
@ 2022-07-22 10:07 Dan Carpenter
  2022-07-22 10:29 ` Vincent MAILHOL
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-07-22 10:07 UTC (permalink / raw)
  To: mailhol.vincent; +Cc: kernel-janitors

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] can: pch_can: do not report txerr and rxerr during bus-off
  2022-07-22 10:07 [bug report] can: pch_can: do not report txerr and rxerr during bus-off Dan Carpenter
@ 2022-07-22 10:29 ` Vincent MAILHOL
  0 siblings, 0 replies; 2+ messages in thread
From: Vincent MAILHOL @ 2022-07-22 10:29 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: kernel-janitors

On Fri. 22 Jul. 2022 at 19:07, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 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'.

Hi Dan,

Thanks for the report, this bug has already been resolved in below
commit (already in net-next branch):
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=9950f1121133

Yours sincerely,
Vincent Mailhol

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-22 10:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-22 10:07 [bug report] can: pch_can: do not report txerr and rxerr during bus-off Dan Carpenter
2022-07-22 10:29 ` Vincent MAILHOL

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.