net/mac80211/cfg.c:1941:17: sparse: sparse: incorrect type in initializer (different base types)

From: kernel test robot

Date: Sun Dec 06 2026 - 06:30:15 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 28a23309c8e40d651faf4cc3cc9b71458a11b987
commit: e70df36f3609b77c0800eb6e15f5dd77b940d22d wifi: mac80211: protect AP template pointers with a spinlock
date: 8 weeks ago
config: mips-randconfig-r2306-20261203 (https://download.01.org/0day-ci/archive/20261205/20261205155358.eMGGwAea-lkp@xxxxxxxxx/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
sparse: v0.6.5-rc1-94-g0d159c10
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261205/20261205155358.eMGGwAea-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Fixes: e70df36f3609 ("wifi: mac80211: protect AP template pointers with a spinlock")
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261205155358.eMGGwAea-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> net/mac80211/cfg.c:1941:17: sparse: sparse: incorrect type in initializer (different base types) @@ expected void *__tmp @@ got struct beacon_data * @@
net/mac80211/cfg.c:1941:17: sparse: expected void *__tmp
net/mac80211/cfg.c:1941:17: sparse: got struct beacon_data *
net/mac80211/cfg.c:387:48: sparse: sparse: Initializer entry defined twice
net/mac80211/cfg.c:387:48: sparse: also defined here
net/mac80211/cfg.c:397:45: sparse: sparse: Initializer entry defined twice
net/mac80211/cfg.c:397:45: sparse: also defined here
net/mac80211/cfg.c:1131:15: sparse: sparse: Initializer entry defined twice
net/mac80211/cfg.c:1131:15: sparse: also defined here
net/mac80211/cfg.c:1175:23: sparse: sparse: Initializer entry defined twice
net/mac80211/cfg.c:1175:23: sparse: also defined here
net/mac80211/cfg.c:1211:23: sparse: sparse: Initializer entry defined twice
net/mac80211/cfg.c:1211:23: sparse: also defined here
net/mac80211/cfg.c:1241:15: sparse: sparse: Initializer entry defined twice
net/mac80211/cfg.c:1241:15: sparse: also defined here
net/mac80211/cfg.c:1281:15: sparse: sparse: Initializer entry defined twice
net/mac80211/cfg.c:1281:15: sparse: also defined here
net/mac80211/cfg.c:1541:15: sparse: sparse: Initializer entry defined twice
net/mac80211/cfg.c:1541:15: sparse: also defined here
net/mac80211/cfg.c:3179:26: sparse: sparse: Initializer entry defined twice
net/mac80211/cfg.c:3179:26: sparse: also defined here
net/mac80211/cfg.c:4340:22: sparse: sparse: Initializer entry defined twice
net/mac80211/cfg.c:4340:22: sparse: also defined here
net/mac80211/cfg.c:4346:25: sparse: sparse: Initializer entry defined twice
net/mac80211/cfg.c:4346:25: sparse: also defined here
net/mac80211/cfg.c:4355:33: sparse: sparse: Initializer entry defined twice
net/mac80211/cfg.c:4355:33: sparse: also defined here
net/mac80211/cfg.c:5169:31: sparse: sparse: Initializer entry defined twice
net/mac80211/cfg.c:5169:31: sparse: also defined here

vim +1941 net/mac80211/cfg.c

1669
1670 static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
1671 struct cfg80211_ap_settings *params)
1672 {
1673 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1674 struct ieee80211_local *local = sdata->local;
1675 struct beacon_data *old;
1676 struct ieee80211_sub_if_data *vlan;
1677 u64 changed = BSS_CHANGED_BEACON_INT |
1678 BSS_CHANGED_BEACON_ENABLED |
1679 BSS_CHANGED_BEACON |
1680 BSS_CHANGED_P2P_PS |
1681 BSS_CHANGED_TXPOWER |
1682 BSS_CHANGED_TWT;
1683 int i, err;
1684 int prev_beacon_int;
1685 unsigned int link_id = params->beacon.link_id;
1686 struct ieee80211_link_data *link;
1687 struct ieee80211_bss_conf *link_conf;
1688 struct ieee80211_chan_req chanreq = {
1689 .oper = params->chandef,
1690 .require_npca = true,
1691 };
1692 u64 tsf;
1693
1694 lockdep_assert_wiphy(local->hw.wiphy);
1695
1696 link = sdata_dereference(sdata->link[link_id], sdata);
1697 if (!link)
1698 return -ENOLINK;
1699
1700 link_conf = link->conf;
1701
1702 old = sdata_dereference(link->u.ap.beacon, sdata);
1703 if (old)
1704 return -EALREADY;
1705
1706 link->smps_mode = IEEE80211_SMPS_OFF;
1707
1708 link->needed_rx_chains = sdata->local->rx_chains;
1709
1710 prev_beacon_int = link_conf->beacon_int;
1711 link_conf->beacon_int = params->beacon_interval;
1712
1713 if (params->ht_cap)
1714 link_conf->ht_ldpc =
1715 params->ht_cap->cap_info &
1716 cpu_to_le16(IEEE80211_HT_CAP_LDPC_CODING);
1717
1718 if (params->vht_cap) {
1719 link_conf->vht_ldpc =
1720 params->vht_cap->vht_cap_info &
1721 cpu_to_le32(IEEE80211_VHT_CAP_RXLDPC);
1722 link_conf->vht_su_beamformer =
1723 params->vht_cap->vht_cap_info &
1724 cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE);
1725 link_conf->vht_su_beamformee =
1726 params->vht_cap->vht_cap_info &
1727 cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE);
1728 link_conf->vht_mu_beamformer =
1729 params->vht_cap->vht_cap_info &
1730 cpu_to_le32(IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE);
1731 link_conf->vht_mu_beamformee =
1732 params->vht_cap->vht_cap_info &
1733 cpu_to_le32(IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE);
1734 }
1735
1736 if (params->he_cap && params->beacon.he_oper) {
1737 link_conf->he_support = true;
1738 link_conf->htc_trig_based_pkt_ext =
1739 le32_get_bits(params->beacon.he_oper->he_oper_params,
1740 IEEE80211_HE_OPERATION_DFLT_PE_DURATION_MASK);
1741 link_conf->frame_time_rts_th =
1742 le32_get_bits(params->beacon.he_oper->he_oper_params,
1743 IEEE80211_HE_OPERATION_RTS_THRESHOLD_MASK);
1744 changed |= BSS_CHANGED_HE_OBSS_PD;
1745
1746 if (params->beacon.he_bss_color.enabled)
1747 changed |= BSS_CHANGED_HE_BSS_COLOR;
1748 }
1749
1750 if (params->he_cap) {
1751 link_conf->he_ldpc =
1752 params->he_cap->phy_cap_info[1] &
1753 IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD;
1754 link_conf->he_su_beamformer =
1755 params->he_cap->phy_cap_info[3] &
1756 IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER;
1757 link_conf->he_su_beamformee =
1758 params->he_cap->phy_cap_info[4] &
1759 IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE;
1760 link_conf->he_mu_beamformer =
1761 params->he_cap->phy_cap_info[4] &
1762 IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER;
1763 link_conf->he_full_ul_mumimo =
1764 params->he_cap->phy_cap_info[2] &
1765 IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO;
1766 }
1767
1768 if (params->eht_cap) {
1769 if (!link_conf->he_support)
1770 return -EOPNOTSUPP;
1771
1772 link_conf->eht_support = true;
1773
1774 link_conf->eht_su_beamformer =
1775 params->eht_cap->fixed.phy_cap_info[0] &
1776 IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMER;
1777 link_conf->eht_su_beamformee =
1778 params->eht_cap->fixed.phy_cap_info[0] &
1779 IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMEE;
1780 link_conf->eht_mu_beamformer =
1781 params->eht_cap->fixed.phy_cap_info[7] &
1782 (IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_80MHZ |
1783 IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_160MHZ |
1784 IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_320MHZ);
1785 link_conf->eht_80mhz_full_bw_ul_mumimo =
1786 params->eht_cap->fixed.phy_cap_info[7] &
1787 (IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_80MHZ |
1788 IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_160MHZ |
1789 IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_320MHZ);
1790 link_conf->eht_disable_mcs15 =
1791 u8_get_bits(params->beacon.eht_oper->params,
1792 IEEE80211_EHT_OPER_MCS15_DISABLE);
1793 } else {
1794 link_conf->eht_su_beamformer = false;
1795 link_conf->eht_su_beamformee = false;
1796 link_conf->eht_mu_beamformer = false;
1797 }
1798
1799 if (params->beacon.uhr_oper) {
1800 const struct ieee80211_uhr_npca_info *npca;
1801 struct ieee80211_bss_npca_params npca_params = {};
1802
1803 if (!link_conf->eht_support)
1804 return -EOPNOTSUPP;
1805
1806 link_conf->uhr_support = true;
1807
1808 npca = ieee80211_uhr_npca_info(params->beacon.uhr_oper);
1809 if (!npca) {
1810 chanreq.oper.npca_chan = NULL;
1811 chanreq.oper.npca_punctured = 0;
1812 } else {
1813 npca_params.min_dur_thresh =
1814 le32_get_bits(npca->params,
1815 IEEE80211_UHR_NPCA_PARAMS_MIN_DUR_THRESH);
1816 npca_params.switch_delay =
1817 le32_get_bits(npca->params,
1818 IEEE80211_UHR_NPCA_PARAMS_SWITCH_DELAY);
1819 npca_params.switch_back_delay =
1820 le32_get_bits(npca->params,
1821 IEEE80211_UHR_NPCA_PARAMS_SWITCH_BACK_DELAY);
1822 npca_params.init_qsrc =
1823 le32_get_bits(npca->params,
1824 IEEE80211_UHR_NPCA_PARAMS_INIT_QSRC);
1825 npca_params.moplen =
1826 le32_get_bits(npca->params,
1827 IEEE80211_UHR_NPCA_PARAMS_MOPLEN);
1828 npca_params.enabled = true;
1829 }
1830
1831 if (memcmp(&npca_params, &link->conf->npca,
1832 sizeof(npca_params))) {
1833 link->conf->npca = npca_params;
1834 changed |= BSS_CHANGED_NPCA;
1835 }
1836 }
1837
1838 if (sdata->vif.type == NL80211_IFTYPE_AP &&
1839 params->mbssid_config.tx_wdev) {
1840 err = ieee80211_set_ap_mbssid_options(sdata,
1841 &params->mbssid_config,
1842 link_conf);
1843 if (err)
1844 return err;
1845 }
1846
1847 err = ieee80211_link_use_channel(link, &chanreq,
1848 IEEE80211_CHANCTX_SHARED);
1849 if (!err)
1850 ieee80211_link_copy_chanctx_to_vlans(link, false);
1851 if (err) {
1852 link_conf->beacon_int = prev_beacon_int;
1853 return err;
1854 }
1855
1856 /*
1857 * Apply control port protocol, this allows us to
1858 * not encrypt dynamic WEP control frames.
1859 */
1860 sdata->control_port_protocol = params->crypto.control_port_ethertype;
1861 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
1862 sdata->control_port_over_nl80211 =
1863 params->crypto.control_port_over_nl80211;
1864 sdata->control_port_no_preauth =
1865 params->crypto.control_port_no_preauth;
1866
1867 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
1868 vlan->control_port_protocol =
1869 params->crypto.control_port_ethertype;
1870 vlan->control_port_no_encrypt =
1871 params->crypto.control_port_no_encrypt;
1872 vlan->control_port_over_nl80211 =
1873 params->crypto.control_port_over_nl80211;
1874 vlan->control_port_no_preauth =
1875 params->crypto.control_port_no_preauth;
1876 }
1877
1878 link_conf->dtim_period = params->dtim_period;
1879 link_conf->enable_beacon = true;
1880 link_conf->allow_p2p_go_ps = sdata->vif.p2p;
1881 link_conf->twt_responder = params->twt_responder;
1882 link_conf->he_obss_pd = params->he_obss_pd;
1883 link_conf->he_bss_color = params->beacon.he_bss_color;
1884 link_conf->s1g_long_beacon_period = params->s1g_long_beacon_period;
1885 sdata->vif.cfg.s1g = params->chandef.chan->band == NL80211_BAND_S1GHZ;
1886
1887 sdata->vif.cfg.ssid_len = params->ssid_len;
1888 if (params->ssid_len)
1889 memcpy(sdata->vif.cfg.ssid, params->ssid,
1890 params->ssid_len);
1891 link_conf->hidden_ssid =
1892 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
1893
1894 memset(&link_conf->p2p_noa_attr, 0,
1895 sizeof(link_conf->p2p_noa_attr));
1896 link_conf->p2p_noa_attr.oppps_ctwindow =
1897 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
1898 if (params->p2p_opp_ps)
1899 link_conf->p2p_noa_attr.oppps_ctwindow |=
1900 IEEE80211_P2P_OPPPS_ENABLE_BIT;
1901
1902 sdata->beacon_rate_set = false;
1903 if (wiphy_ext_feature_isset(local->hw.wiphy,
1904 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) {
1905 for (i = 0; i < NUM_NL80211_BANDS; i++) {
1906 sdata->beacon_rateidx_mask[i] =
1907 params->beacon_rate.control[i].legacy;
1908 if (sdata->beacon_rateidx_mask[i])
1909 sdata->beacon_rate_set = true;
1910 }
1911 }
1912
1913 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL))
1914 link_conf->beacon_tx_rate = params->beacon_rate;
1915
1916 err = ieee80211_assign_beacon(sdata, link, &params->beacon, NULL, NULL,
1917 &changed);
1918 if (err < 0)
1919 goto error;
1920
1921 err = ieee80211_set_fils_discovery(sdata, &params->fils_discovery,
1922 link, link_conf, &changed);
1923 if (err < 0)
1924 goto error;
1925
1926 err = ieee80211_set_unsol_bcast_probe_resp(sdata,
1927 &params->unsol_bcast_probe_resp,
1928 link, link_conf, &changed);
1929 if (err < 0)
1930 goto error;
1931
1932 if (sdata->vif.cfg.s1g) {
1933 err = ieee80211_set_s1g_short_beacon(sdata, link,
1934 &params->s1g_short_beacon);
1935 if (err < 0)
1936 goto error;
1937 }
1938
1939 err = drv_start_ap(sdata->local, sdata, link_conf);
1940 if (err) {
> 1941 ap_tmpl_replace(link, link->u.ap.beacon, NULL);
1942
1943 if (ieee80211_num_beaconing_links(sdata) == 0)
1944 sdata->u.ap.active = false;
1945
1946 goto error;
1947 }
1948
1949 tsf = drv_get_tsf(local, sdata);
1950 ieee80211_recalc_dtim(sdata, tsf);
1951
1952 if (link->u.ap.s1g_short_beacon)
1953 ieee80211_recalc_sb_count(sdata, tsf);
1954
1955 ieee80211_vif_cfg_change_notify(sdata, BSS_CHANGED_SSID);
1956 ieee80211_link_info_change_notify(sdata, link, changed);
1957
1958 if (ieee80211_num_beaconing_links(sdata) <= 1)
1959 netif_carrier_on(dev);
1960
1961 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1962 netif_carrier_on(vlan->dev);
1963
1964 return 0;
1965
1966 error:
1967 link_conf->enable_beacon = false;
1968 link_conf->beacon_int = prev_beacon_int;
1969 sdata->vif.cfg.ssid_len = 0;
1970 ieee80211_link_release_channel(link);
1971
1972 return err;
1973 }
1974

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki