[mkl-can-next:testing 4/29] drivers/net/can/vxcan.c:60 vxcan_xmit() error: use kfree_skb() here instead of kfree(oskb)

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

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git testing
head:   0691a4b55c89055c1efb61a7696f4bc6aa5cf630
commit: 1574481bb3de11c9d44f5405c17e948b76794f39 [4/29] vxcan: remove sk reference in peer skb
config: arc-randconfig-m031-20220310 (https://download.01.org/0day-ci/archive/20220311/202203110433.qIHMpuS5-lkp@xxxxxxxxx/config)
compiler: arceb-elf-gcc (GCC) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

New smatch warnings:
drivers/net/can/vxcan.c:60 vxcan_xmit() error: use kfree_skb() here instead of kfree(oskb)

vim +60 drivers/net/can/vxcan.c

1574481bb3de11 Oliver Hartkopp           2022-03-09  36  static netdev_tx_t vxcan_xmit(struct sk_buff *oskb, struct net_device *dev)
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  37  {
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  38  	struct vxcan_priv *priv = netdev_priv(dev);
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  39  	struct net_device *peer;
1574481bb3de11 Oliver Hartkopp           2022-03-09  40  	struct canfd_frame *cfd = (struct canfd_frame *)oskb->data;
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  41  	struct net_device_stats *peerstats, *srcstats = &dev->stats;
1574481bb3de11 Oliver Hartkopp           2022-03-09  42  	struct sk_buff *skb;
75854cad5d8097 Vincent Mailhol           2021-01-20  43  	u8 len;
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  44  
1574481bb3de11 Oliver Hartkopp           2022-03-09  45  	if (can_dropped_invalid_skb(dev, oskb))
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  46  		return NETDEV_TX_OK;
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  47  
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  48  	rcu_read_lock();
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  49  	peer = rcu_dereference(priv->peer);
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  50  	if (unlikely(!peer)) {
1574481bb3de11 Oliver Hartkopp           2022-03-09  51  		kfree_skb(oskb);
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  52  		dev->stats.tx_dropped++;
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  53  		goto out_unlock;
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  54  	}
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  55  
1574481bb3de11 Oliver Hartkopp           2022-03-09  56  	skb = skb_clone(oskb, GFP_ATOMIC);
1574481bb3de11 Oliver Hartkopp           2022-03-09  57  	if (skb) {
1574481bb3de11 Oliver Hartkopp           2022-03-09  58  		consume_skb(oskb);
1574481bb3de11 Oliver Hartkopp           2022-03-09  59  	} else {
1574481bb3de11 Oliver Hartkopp           2022-03-09 @60  		kfree(oskb);

kfree_skb(oskb);

a8f820a380a2a0 Oliver Hartkopp           2017-04-25  61  		goto out_unlock;
1574481bb3de11 Oliver Hartkopp           2022-03-09  62  	}
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  63  
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  64  	/* reset CAN GW hop counter */
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  65  	skb->csum_start = 0;
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  66  	skb->pkt_type   = PACKET_BROADCAST;
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  67  	skb->dev        = peer;
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  68  	skb->ip_summed  = CHECKSUM_UNNECESSARY;
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  69  
cc4b08c31b5c51 Vincent Mailhol           2021-12-07  70  	len = cfd->can_id & CAN_RTR_FLAG ? 0 : cfd->len;
00f4a0afb7eafd Sebastian Andrzej Siewior 2022-03-05  71  	if (netif_rx(skb) == NET_RX_SUCCESS) {
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  72  		srcstats->tx_packets++;
75854cad5d8097 Vincent Mailhol           2021-01-20  73  		srcstats->tx_bytes += len;
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  74  		peerstats = &peer->stats;
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  75  		peerstats->rx_packets++;
75854cad5d8097 Vincent Mailhol           2021-01-20  76  		peerstats->rx_bytes += len;
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  77  	}
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  78  
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  79  out_unlock:
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  80  	rcu_read_unlock();
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  81  	return NETDEV_TX_OK;
a8f820a380a2a0 Oliver Hartkopp           2017-04-25  82  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx




[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