[bug report] can: kvaser_usb: Split driver into kvaser_usb_core.c and kvaser_usb_leaf.c

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

 



Hello Jimmy Assarsson,

The patch 7259124eac7d: "can: kvaser_usb: Split driver into
kvaser_usb_core.c and kvaser_usb_leaf.c" from Jul 18, 2018, leads to
the following static checker warning:

	drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c:549 kvaser_usb_start_xmit()
	warn: passing freed memory 'skb'

drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
   518          urb = usb_alloc_urb(0, GFP_ATOMIC);
   519          if (!urb) {
   520                  stats->tx_dropped++;
   521                  dev_kfree_skb(skb);
   522                  return NETDEV_TX_OK;
   523          }
   524  
   525          spin_lock_irqsave(&priv->tx_contexts_lock, flags);
   526          for (i = 0; i < dev->max_tx_urbs; i++) {
   527                  if (priv->tx_contexts[i].echo_index == dev->max_tx_urbs) {
   528                          context = &priv->tx_contexts[i];
   529  
   530                          context->echo_index = i;
   531                          can_put_echo_skb(skb, netdev, context->echo_index);
                                                 ^^^
Smatch thinks this can be freed on some paths.  Seems reasonable to the
uninitiated.

   532                          ++priv->active_tx_contexts;
   533                          if (priv->active_tx_contexts >= (int)dev->max_tx_urbs)
   534                                  netif_stop_queue(netdev);
   535  
   536                          break;
   537                  }
   538          }
   539          spin_unlock_irqrestore(&priv->tx_contexts_lock, flags);
   540  
   541          /* This should never happen; it implies a flow control bug */
   542          if (!context) {
   543                  netdev_warn(netdev, "cannot find free context\n");
   544  
   545                  ret = NETDEV_TX_BUSY;
   546                  goto freeurb;
   547          }
   548  
   549          buf = dev->ops->dev_frame_to_cmd(priv, skb, &context->dlc, &cmd_len,
                                                       ^^^

   550                                           context->echo_index);


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