Search Linux Wireless

[bug report] wifi: iwlwifi: map entire SKB when sending AMSDUs

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

 



Hello Benjamin Berg,

Commit 7f5e3038f029 ("wifi: iwlwifi: map entire SKB when sending
AMSDUs") from Jul 3, 2024 (linux-next), leads to the following Smatch
static checker warning:

	drivers/net/wireless/intel/iwlwifi/pcie/tx.c:1879 iwl_pcie_prep_tso()
	warn: error code type promoted to positive: 'sgt->orig_nents'

drivers/net/wireless/intel/iwlwifi/pcie/tx.c
    1855 struct sg_table *iwl_pcie_prep_tso(struct iwl_trans *trans, struct sk_buff *skb,
    1856                                    struct iwl_cmd_meta *cmd_meta,
    1857                                    u8 **hdr, unsigned int hdr_room)
    1858 {
    1859         struct sg_table *sgt;
    1860 
    1861         if (WARN_ON_ONCE(skb_has_frag_list(skb)))
    1862                 return NULL;
    1863 
    1864         *hdr = iwl_pcie_get_page_hdr(trans,
    1865                                      hdr_room + __alignof__(struct sg_table) +
    1866                                      sizeof(struct sg_table) +
    1867                                      (skb_shinfo(skb)->nr_frags + 1) *
    1868                                      sizeof(struct scatterlist),
    1869                                      skb);
    1870         if (!*hdr)
    1871                 return NULL;
    1872 
    1873         sgt = (void *)PTR_ALIGN(*hdr + hdr_room, __alignof__(struct sg_table));
    1874         sgt->sgl = (void *)(sgt + 1);
    1875 
    1876         sg_init_table(sgt->sgl, skb_shinfo(skb)->nr_frags + 1);
    1877 
    1878         sgt->orig_nents = skb_to_sgvec(skb, sgt->sgl, 0, skb->len);
--> 1879         if (WARN_ON_ONCE(sgt->orig_nents <= 0))

skb_to_sgvec() returns negative error codes but sgt->orig_nents is a u32 so
the error handling doesn't work.  Need to either change the type or add a cast.

    1880                 return NULL;
    1881 
    1882         /* And map the entire SKB */
    1883         if (dma_map_sgtable(trans->dev, sgt, DMA_TO_DEVICE, 0) < 0)
    1884                 return NULL;
    1885 
    1886         /* Store non-zero (i.e. valid) offset for unmapping */
    1887         cmd_meta->sg_offset = (unsigned long) sgt & ~PAGE_MASK;
    1888 
    1889         return sgt;
    1890 }

regards,
dan carpenter




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux