Re: [PATCH] Staging: rtlwifi: Remove NULL pointer dereference

From: kbuild test robot
Date: Wed Oct 11 2017 - 15:12:12 EST


Hi Shreeya,

[auto build test WARNING on staging/staging-testing]
[also build test WARNING on v4.14-rc4 next-20171009]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Shreeya-Patel/Staging-rtlwifi-Remove-NULL-pointer-dereference/20171012-021213
config: alpha-allyesconfig (attached as .config)
compiler: alpha-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=alpha

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

drivers/staging//rtlwifi/base.c: In function 'rtl_get_tcb_desc':
>> drivers/staging//rtlwifi/base.c:778:26: warning: 'sta_entry' may be used uninitialized in this function [-Wmaybe-uninitialized]
(sta_entry ? sta_entry->wireless_mode : \
^~
drivers/staging//rtlwifi/base.c:784:23: note: 'sta_entry' was declared here
struct rtl_sta_info *sta_entry;
^~~~~~~~~

vim +/sta_entry +778 drivers/staging//rtlwifi/base.c

56bde846 Ping-Ke Shih 2017-08-17 770
56bde846 Ping-Ke Shih 2017-08-17 771 static void _rtl_txrate_selectmode(struct ieee80211_hw *hw,
56bde846 Ping-Ke Shih 2017-08-17 772 struct ieee80211_sta *sta,
56bde846 Ping-Ke Shih 2017-08-17 773 struct rtl_tcb_desc *tcb_desc)
56bde846 Ping-Ke Shih 2017-08-17 774 {
56bde846 Ping-Ke Shih 2017-08-17 775 #define SET_RATE_ID(rate_id) \
56bde846 Ping-Ke Shih 2017-08-17 776 ((rtlpriv->cfg->spec_ver & RTL_SPEC_NEW_RATEID) ? \
56bde846 Ping-Ke Shih 2017-08-17 777 rtl_mrate_idx_to_arfr_id(hw, rate_id, \
56bde846 Ping-Ke Shih 2017-08-17 @778 (sta_entry ? sta_entry->wireless_mode : \
56bde846 Ping-Ke Shih 2017-08-17 779 WIRELESS_MODE_G)) : \
56bde846 Ping-Ke Shih 2017-08-17 780 rate_id)
56bde846 Ping-Ke Shih 2017-08-17 781
56bde846 Ping-Ke Shih 2017-08-17 782 struct rtl_priv *rtlpriv = rtl_priv(hw);
56bde846 Ping-Ke Shih 2017-08-17 783 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
f651dc66 Shreeya Patel 2017-10-10 784 struct rtl_sta_info *sta_entry;
56bde846 Ping-Ke Shih 2017-08-17 785 u8 ratr_index = SET_RATE_ID(RATR_INX_WIRELESS_MC);
56bde846 Ping-Ke Shih 2017-08-17 786
56bde846 Ping-Ke Shih 2017-08-17 787 if (sta) {
56bde846 Ping-Ke Shih 2017-08-17 788 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
56bde846 Ping-Ke Shih 2017-08-17 789 ratr_index = sta_entry->ratr_index;
56bde846 Ping-Ke Shih 2017-08-17 790 }
56bde846 Ping-Ke Shih 2017-08-17 791 if (!tcb_desc->disable_ratefallback || !tcb_desc->use_driver_rate) {
56bde846 Ping-Ke Shih 2017-08-17 792 if (mac->opmode == NL80211_IFTYPE_STATION) {
56bde846 Ping-Ke Shih 2017-08-17 793 tcb_desc->ratr_index = 0;
56bde846 Ping-Ke Shih 2017-08-17 794 } else if (mac->opmode == NL80211_IFTYPE_ADHOC ||
56bde846 Ping-Ke Shih 2017-08-17 795 mac->opmode == NL80211_IFTYPE_MESH_POINT) {
56bde846 Ping-Ke Shih 2017-08-17 796 if (tcb_desc->multicast || tcb_desc->broadcast) {
56bde846 Ping-Ke Shih 2017-08-17 797 tcb_desc->hw_rate =
56bde846 Ping-Ke Shih 2017-08-17 798 rtlpriv->cfg->maps[RTL_RC_CCK_RATE2M];
56bde846 Ping-Ke Shih 2017-08-17 799 tcb_desc->use_driver_rate = 1;
56bde846 Ping-Ke Shih 2017-08-17 800 tcb_desc->ratr_index =
56bde846 Ping-Ke Shih 2017-08-17 801 SET_RATE_ID(RATR_INX_WIRELESS_MC);
56bde846 Ping-Ke Shih 2017-08-17 802 } else {
56bde846 Ping-Ke Shih 2017-08-17 803 tcb_desc->ratr_index = ratr_index;
56bde846 Ping-Ke Shih 2017-08-17 804 }
56bde846 Ping-Ke Shih 2017-08-17 805 } else if (mac->opmode == NL80211_IFTYPE_AP) {
56bde846 Ping-Ke Shih 2017-08-17 806 tcb_desc->ratr_index = ratr_index;
56bde846 Ping-Ke Shih 2017-08-17 807 }
56bde846 Ping-Ke Shih 2017-08-17 808 }
56bde846 Ping-Ke Shih 2017-08-17 809
56bde846 Ping-Ke Shih 2017-08-17 810 if (rtlpriv->dm.useramask) {
56bde846 Ping-Ke Shih 2017-08-17 811 tcb_desc->ratr_index = ratr_index;
56bde846 Ping-Ke Shih 2017-08-17 812 /* TODO we will differentiate adhoc and station future */
56bde846 Ping-Ke Shih 2017-08-17 813 if (mac->opmode == NL80211_IFTYPE_STATION ||
56bde846 Ping-Ke Shih 2017-08-17 814 mac->opmode == NL80211_IFTYPE_MESH_POINT) {
56bde846 Ping-Ke Shih 2017-08-17 815 tcb_desc->mac_id = 0;
56bde846 Ping-Ke Shih 2017-08-17 816
56bde846 Ping-Ke Shih 2017-08-17 817 if (sta &&
56bde846 Ping-Ke Shih 2017-08-17 818 (rtlpriv->cfg->spec_ver & RTL_SPEC_NEW_RATEID))
56bde846 Ping-Ke Shih 2017-08-17 819 ; /* use sta_entry->ratr_index */
56bde846 Ping-Ke Shih 2017-08-17 820 else if (mac->mode == WIRELESS_MODE_AC_5G)
56bde846 Ping-Ke Shih 2017-08-17 821 tcb_desc->ratr_index =
56bde846 Ping-Ke Shih 2017-08-17 822 SET_RATE_ID(RATR_INX_WIRELESS_AC_5N);
56bde846 Ping-Ke Shih 2017-08-17 823 else if (mac->mode == WIRELESS_MODE_AC_24G)
56bde846 Ping-Ke Shih 2017-08-17 824 tcb_desc->ratr_index =
56bde846 Ping-Ke Shih 2017-08-17 825 SET_RATE_ID(RATR_INX_WIRELESS_AC_24N);
56bde846 Ping-Ke Shih 2017-08-17 826 else if (mac->mode == WIRELESS_MODE_N_24G)
56bde846 Ping-Ke Shih 2017-08-17 827 tcb_desc->ratr_index =
56bde846 Ping-Ke Shih 2017-08-17 828 SET_RATE_ID(RATR_INX_WIRELESS_NGB);
56bde846 Ping-Ke Shih 2017-08-17 829 else if (mac->mode == WIRELESS_MODE_N_5G)
56bde846 Ping-Ke Shih 2017-08-17 830 tcb_desc->ratr_index =
56bde846 Ping-Ke Shih 2017-08-17 831 SET_RATE_ID(RATR_INX_WIRELESS_NG);
56bde846 Ping-Ke Shih 2017-08-17 832 else if (mac->mode & WIRELESS_MODE_G)
56bde846 Ping-Ke Shih 2017-08-17 833 tcb_desc->ratr_index =
56bde846 Ping-Ke Shih 2017-08-17 834 SET_RATE_ID(RATR_INX_WIRELESS_GB);
56bde846 Ping-Ke Shih 2017-08-17 835 else if (mac->mode & WIRELESS_MODE_B)
56bde846 Ping-Ke Shih 2017-08-17 836 tcb_desc->ratr_index =
56bde846 Ping-Ke Shih 2017-08-17 837 SET_RATE_ID(RATR_INX_WIRELESS_B);
56bde846 Ping-Ke Shih 2017-08-17 838 else if (mac->mode & WIRELESS_MODE_A)
56bde846 Ping-Ke Shih 2017-08-17 839 tcb_desc->ratr_index =
56bde846 Ping-Ke Shih 2017-08-17 840 SET_RATE_ID(RATR_INX_WIRELESS_G);
56bde846 Ping-Ke Shih 2017-08-17 841
56bde846 Ping-Ke Shih 2017-08-17 842 } else if (mac->opmode == NL80211_IFTYPE_AP ||
56bde846 Ping-Ke Shih 2017-08-17 843 mac->opmode == NL80211_IFTYPE_ADHOC) {
56bde846 Ping-Ke Shih 2017-08-17 844 if (sta) {
56bde846 Ping-Ke Shih 2017-08-17 845 if (sta->aid > 0)
56bde846 Ping-Ke Shih 2017-08-17 846 tcb_desc->mac_id = sta->aid + 1;
56bde846 Ping-Ke Shih 2017-08-17 847 else
56bde846 Ping-Ke Shih 2017-08-17 848 tcb_desc->mac_id = 1;
56bde846 Ping-Ke Shih 2017-08-17 849 } else {
56bde846 Ping-Ke Shih 2017-08-17 850 tcb_desc->mac_id = 0;
56bde846 Ping-Ke Shih 2017-08-17 851 }
56bde846 Ping-Ke Shih 2017-08-17 852 }
56bde846 Ping-Ke Shih 2017-08-17 853 }
56bde846 Ping-Ke Shih 2017-08-17 854 #undef SET_RATE_ID
56bde846 Ping-Ke Shih 2017-08-17 855 }
56bde846 Ping-Ke Shih 2017-08-17 856

:::::: The code at line 778 was first introduced by commit
:::::: 56bde846304ea05d5f8c8de0e3a42627a7a92be6 staging: r8822be: Add existing rtlwifi and rtl_pci parts for new driver

:::::: TO: Ping-Ke Shih <pkshih@xxxxxxxxxxx>
:::::: CC: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Attachment: .config.gz
Description: application/gzip