[bug report] wcn36xx: check dma_mapping_error()
Dan Carpenter
dan.carpenter at oracle.com
Thu Aug 25 09:10:12 PDT 2022
Hello Rob Clark,
The patch 4165cf7ba52a: "wcn36xx: check dma_mapping_error()" from Jul
3, 2017, leads to the following Smatch static checker warning:
drivers/net/wireless/ath/wcn36xx/dxe.c:305 wcn36xx_dxe_fill_skb()
warn: 'dxe->dst_addr_l' is not a DMA mapping error
drivers/net/wireless/ath/wcn36xx/dxe.c:805 wcn36xx_dxe_tx_frame()
warn: 'desc_skb->src_addr_l' is not a DMA mapping error
drivers/net/wireless/ath/wcn36xx/dxe.c
290 static int wcn36xx_dxe_fill_skb(struct device *dev,
291 struct wcn36xx_dxe_ctl *ctl,
292 gfp_t gfp)
293 {
294 struct wcn36xx_dxe_desc *dxe = ctl->desc;
295 struct sk_buff *skb;
296
297 skb = alloc_skb(WCN36XX_PKT_SIZE, gfp);
298 if (skb == NULL)
299 return -ENOMEM;
300
301 dxe->dst_addr_l = dma_map_single(dev,
302 skb_tail_pointer(skb),
303 WCN36XX_PKT_SIZE,
304 DMA_FROM_DEVICE);
--> 305 if (dma_mapping_error(dev, dxe->dst_addr_l)) {
I'm so surprised that adding this check fixed a bug. There is an
addr_l and addr_h (presumably for the low and high bits of the address?)
The ->dst_addr_h is never used.
A 32bit dst_addr_l can't be equal to DMA_MAPPING_ERROR unless it's a 32
bit system-ish.
306 dev_err(dev, "unable to map skb\n");
307 kfree_skb(skb);
308 return -ENOMEM;
309 }
310 ctl->skb = skb;
311
312 return 0;
313 }
regards,
dan carpenter
More information about the wcn36xx
mailing list