staging: wilc1000: GetIfHandler: add argument struct wilc and use it

Dan Carpenter dan.carpenter at oracle.com
Tue Nov 3 12:07:50 UTC 2015


Hello Glen Lee,

This is a semi-automatic email about new static checker warnings.

The patch 4ad81fd6125f: "staging: wilc1000: GetIfHandler: add 
argument struct wilc and use it" from Oct 27, 2015, leads to the 
following Smatch complaint:

drivers/staging/wilc1000/linux_wlan.c:1590 frmw_to_linux()
	 warn: variable dereferenced before check 'wilc' (see line 1571)

drivers/staging/wilc1000/linux_wlan.c
  1570	
  1571		wilc_netdev = GetIfHandler(wilc, buff);
                                           ^^^^
New dereference (inside the function call).

  1572		if (wilc_netdev == NULL)
  1573			return;
  1574	
  1575		buff += pkt_offset;
  1576		nic = netdev_priv(wilc_netdev);
  1577	
  1578		if (size > 0) {
  1579	
  1580			frame_len = size;
  1581			buff_to_send = buff;
  1582	
  1583			/* Need to send the packet up to the host, allocate a skb buffer */
  1584			skb = dev_alloc_skb(frame_len);
  1585			if (skb == NULL) {
  1586				PRINT_ER("Low memory - packet droped\n");
  1587				return;
  1588			}
  1589	
  1590			if (wilc == NULL || wilc_netdev == NULL)
                            ^^^^^^^^^^^^
Old code assumes wilc can be NULL.

  1591				PRINT_ER("wilc_netdev in wilc is NULL");
  1592			skb->dev = wilc_netdev;

regards,
dan carpenter


More information about the devel mailing list