[bug report] can: kvaser_usb: Add support for Kvaser USB hydra family

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Jimmy Assarsson,

The patch aec5fb2268b7: "can: kvaser_usb: Add support for Kvaser USB
hydra family" from Jul 18, 2018, leads to the following static
checker warning:

	drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:1035 kvaser_usb_hydra_error_frame()
	error: potentially dereferencing uninitialized 'cf'.

drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
  1010          skb = alloc_can_err_skb(netdev, &cf);
                                                ^^^
Assume this fails and skb is NULL.

  1011  
  1012          if (new_state != old_state) {
  1013                  if (skb) {
                            ^^^
  1014                          enum can_state tx_state, rx_state;
  1015  
  1016                          tx_state = (bec.txerr >= bec.rxerr) ?
  1017                                          new_state : CAN_STATE_ERROR_ACTIVE;
  1018                          rx_state = (bec.txerr <= bec.rxerr) ?
  1019                                          new_state : CAN_STATE_ERROR_ACTIVE;
  1020  
  1021                          can_change_state(netdev, cf, tx_state, rx_state);
  1022                  }
  1023  
  1024                  if (new_state == CAN_STATE_BUS_OFF) {
  1025                          if (!priv->can.restart_ms)
  1026                                  kvaser_usb_hydra_send_simple_cmd_async
  1027                                                  (priv, CMD_STOP_CHIP_REQ);
  1028  
  1029                          can_bus_off(netdev);
  1030                  }
  1031  
  1032                  if (priv->can.restart_ms &&
  1033                      old_state >= CAN_STATE_BUS_OFF &&
  1034                      new_state < CAN_STATE_BUS_OFF)
  1035                          cf->can_id |= CAN_ERR_RESTARTED;
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Potentially uninitialized

  1036          }
  1037  
  1038          if (!skb) {
                    ^^^^^
  1039                  stats->rx_dropped++;
  1040                  netdev_warn(netdev, "No memory left for err_skb\n");
  1041                  return;
  1042          }

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-can" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux