Message ID | 20200225074105.7740-1-ajay.kathat@microchip.com (mailing list archive) |
---|---|
Headers | show |
Series | wilc1000: move out of staging | expand |
There are a few static checker warnings from Friday's linux-next. Only the first one is important. (Not all these Smatch warnings have been published). drivers/staging/wilc1000/hif.c:804 wilc_hif_pack_sta_param() warn: '¶ms->ht_capa' sometimes too small '8' size = 29 drivers/staging/wilc1000/hif.c 787 static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac, 788 struct station_parameters *params) 789 { 790 ether_addr_copy(cur_byte, mac); 791 cur_byte += ETH_ALEN; 792 793 put_unaligned_le16(params->aid, cur_byte); 794 cur_byte += 2; 795 796 *cur_byte++ = params->supported_rates_len; 797 if (params->supported_rates_len > 0) 798 memcpy(cur_byte, params->supported_rates, 799 params->supported_rates_len); 800 cur_byte += params->supported_rates_len; 801 802 if (params->ht_capa) { 803 *cur_byte++ = true; 804 memcpy(cur_byte, ¶ms->ht_capa, ^^^^^^^^^^^^^^^^ This is copying the wrong data. The "&" is wrong. 805 sizeof(struct ieee80211_ht_cap)); 806 } else { 807 *cur_byte++ = false; 808 } 809 cur_byte += sizeof(struct ieee80211_ht_cap); 810 811 put_unaligned_le16(params->sta_flags_mask, cur_byte); 812 cur_byte += 2; 813 put_unaligned_le16(params->sta_flags_set, cur_byte); 814 } drivers/staging/wilc1000/cfg80211.c:904 del_pmksa() warn: 'i < priv->pmkid_list.numpmkid' 'true' implies 'priv->pmkid_list.numpmkid > 0' is 'true' drivers/staging/wilc1000/cfg80211.c 887 static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev, 888 struct cfg80211_pmksa *pmksa) 889 { 890 u32 i; 891 int ret = 0; 892 struct wilc_vif *vif = netdev_priv(netdev); 893 struct wilc_priv *priv = &vif->priv; 894 895 for (i = 0; i < priv->pmkid_list.numpmkid; i++) { 896 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, 897 ETH_ALEN)) { 898 memset(&priv->pmkid_list.pmkidlist[i], 0, 899 sizeof(struct wilc_pmkid)); 900 break; 901 } 902 } 903 904 if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This part of the condition is a given (must be true). Delete it. It's better to reverse the test and say: if (i == priv->pmkid_list.numpmkid) return -EINVAL; 905 for (; i < (priv->pmkid_list.numpmkid - 1); i++) { 906 memcpy(priv->pmkid_list.pmkidlist[i].bssid, 907 priv->pmkid_list.pmkidlist[i + 1].bssid, 908 ETH_ALEN); 909 memcpy(priv->pmkid_list.pmkidlist[i].pmkid, 910 priv->pmkid_list.pmkidlist[i + 1].pmkid, 911 WLAN_PMKID_LEN); 912 } 913 priv->pmkid_list.numpmkid--; 914 } else { 915 ret = -EINVAL; 916 } 917 918 return ret; 919 } drivers/staging/wilc1000/wlan.c:706 wilc_wlan_handle_rx_buff() warn: 'pkt_len' 'true' implies 'pkt_len > 0' is 'true' drivers/staging/wilc1000/wlan.c 686 int is_cfg_packet; 687 u8 *buff_ptr; 688 689 do { 690 buff_ptr = buffer + offset; 691 header = get_unaligned_le32(buff_ptr); 692 693 is_cfg_packet = FIELD_GET(WILC_PKT_HDR_CONFIG_FIELD, header); 694 pkt_offset = FIELD_GET(WILC_PKT_HDR_OFFSET_FIELD, header); 695 tp_len = FIELD_GET(WILC_PKT_HDR_TOTAL_LEN_FIELD, header); 696 pkt_len = FIELD_GET(WILC_PKT_HDR_LEN_FIELD, header); 697 698 if (pkt_len == 0 || tp_len == 0) ^^^^^^^^^^^^ 699 break; 700 701 if (pkt_offset & IS_MANAGMEMENT) { 702 buff_ptr += HOST_HDR_OFFSET; 703 wilc_wfi_mgmt_rx(wilc, buff_ptr, pkt_len); 704 } else { 705 if (!is_cfg_packet) { 706 if (pkt_len > 0) { ^^^^^^^^^^^ Delete. 707 wilc_frmw_to_host(wilc, buff_ptr, 708 pkt_len, pkt_offset); 709 } 710 } else { 711 struct wilc_cfg_rsp rsp; 712 713 buff_ptr += pkt_offset; 714 regards, dan carpenter
Hi Dan, On 02/03/20 2:53 pm, Dan Carpenter wrote: > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe > > There are a few static checker warnings from Friday's linux-next. Only > the first one is important. (Not all these Smatch warnings have been > published). Thanks. I have submitted a patch series to address Smatch static checker warnings in staging ml. I will send v4 for this series by including those changes. Regards Ajay
From: Ajay Singh <ajay.kathat@microchip.com> This patch series is to review and move wilc1000 driver out of staging. Most of the review comments received in [1] & [2] are addressed in the latest code. Please review and provide your inputs. [1]. https://lore.kernel.org/linux-wireless/1537957525-11467-1-git-send-email-ajay.kathat@microchip.com/ [2]. https://lore.kernel.org/linux-wireless/1562896697-8002-1-git-send-email-ajay.kathat@microchip.com/ Changes since v2: - use 'struct' to extract FW info from received commands. - make use of C style comments instead of C++. - remove use of bool type for firmware struct. - deleted unused code related to interrupt handling. - make use of RCU list to maintain interfaces list. - remove 'wilc_' prefix from file name. - added 'WILC_' prefix for header guard macro. - remove use of infinite loops(i.e. while(1)). - move firmware realted struct to a separate file. - refactor SPI command handling by using 'struct'. - use different functions to handle different SPI commands. - remove use of vendor specific IE for p2p handling. - refactor p2p related code to avoid use of buf pointer operation. - make use of FIELD_GET/PREP macro. - use #define instead of magic values. - use YAML schemes for DT binding documentation. - deleted unused code from spi.c and sdio.c. - added changes for few issues reported by smatch static code analyzer. Changes since v1: - remove use of shadow buffer to keep scan result. - remove internal messaging flow to handle cfg80211_ops. - make use of cfg80211 provide API. - use 'struct' for packing firmware commands. - make use of kernel API's and Macro. - remove unnecessary log messages - supported dynamically add/remove interfaces. - cleanup and deleted around 3.3k lines of code. Ajay Singh (18): wilc1000: add hif.h wilc1000: add hif.c wilc1000: add wlan_if.h wilc1000: add wlan_cfg.h wilc1000: add wlan_cfg.c wilc1000: add cfg80211.c wilc1000: add cfg80211.h wilc1000: add netdev.h wilc1000: add netdev.c wilc1000: add mon.c wilc1000: add spi.c wilc1000: add wlan.h wilc1000: add wlan.c wilc1000: add sdio.c wilc1000: add fw.h dt: bindings: net: add microchip,wilc1000,sdio.yaml dt: bindings: net: add microchip,wilc1000,spi.yaml wilc1000: add Makefile and Kconfig files for wilc1000 compilation .../net/wireless/microchip,wilc1000,sdio.yaml | 68 + .../net/wireless/microchip,wilc1000,spi.yaml | 61 + drivers/net/wireless/Kconfig | 1 + drivers/net/wireless/Makefile | 1 + drivers/net/wireless/microchip/Kconfig | 15 + drivers/net/wireless/microchip/Makefile | 2 + .../net/wireless/microchip/wilc1000/Kconfig | 42 + .../net/wireless/microchip/wilc1000/Makefile | 14 + .../wireless/microchip/wilc1000/cfg80211.c | 1852 ++++++++++++++++ .../wireless/microchip/wilc1000/cfg80211.h | 29 + drivers/net/wireless/microchip/wilc1000/fw.h | 119 + drivers/net/wireless/microchip/wilc1000/hif.c | 1959 +++++++++++++++++ drivers/net/wireless/microchip/wilc1000/hif.h | 214 ++ drivers/net/wireless/microchip/wilc1000/mon.c | 260 +++ .../net/wireless/microchip/wilc1000/netdev.c | 940 ++++++++ .../net/wireless/microchip/wilc1000/netdev.h | 295 +++ .../net/wireless/microchip/wilc1000/sdio.c | 1030 +++++++++ drivers/net/wireless/microchip/wilc1000/spi.c | 1001 +++++++++ .../net/wireless/microchip/wilc1000/wlan.c | 1240 +++++++++++ .../net/wireless/microchip/wilc1000/wlan.h | 398 ++++ .../wireless/microchip/wilc1000/wlan_cfg.c | 413 ++++ .../wireless/microchip/wilc1000/wlan_cfg.h | 54 + .../net/wireless/microchip/wilc1000/wlan_if.h | 803 +++++++ drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - 25 files changed, 10811 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,sdio.yaml create mode 100644 Documentation/devicetree/bindings/net/wireless/microchip,wilc1000,spi.yaml create mode 100644 drivers/net/wireless/microchip/Kconfig create mode 100644 drivers/net/wireless/microchip/Makefile create mode 100644 drivers/net/wireless/microchip/wilc1000/Kconfig create mode 100644 drivers/net/wireless/microchip/wilc1000/Makefile create mode 100644 drivers/net/wireless/microchip/wilc1000/cfg80211.c create mode 100644 drivers/net/wireless/microchip/wilc1000/cfg80211.h create mode 100644 drivers/net/wireless/microchip/wilc1000/fw.h create mode 100644 drivers/net/wireless/microchip/wilc1000/hif.c create mode 100644 drivers/net/wireless/microchip/wilc1000/hif.h create mode 100644 drivers/net/wireless/microchip/wilc1000/mon.c create mode 100644 drivers/net/wireless/microchip/wilc1000/netdev.c create mode 100644 drivers/net/wireless/microchip/wilc1000/netdev.h create mode 100644 drivers/net/wireless/microchip/wilc1000/sdio.c create mode 100644 drivers/net/wireless/microchip/wilc1000/spi.c create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan.c create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan.h create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan_cfg.c create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan_cfg.h create mode 100644 drivers/net/wireless/microchip/wilc1000/wlan_if.h