mt76: usb: fix warning in mt76u_buf_free
authorLorenzo Bianconi <lorenzo@kernel.org>
Wed, 20 Feb 2019 23:57:19 +0000 (00:57 +0100)
committerFelix Fietkau <nbd@nbd.name>
Tue, 26 Feb 2019 11:25:18 +0000 (12:25 +0100)
Fix following static checker warning in mt76u_buf_free:
  drivers/net/wireless/mediatek/mt76/usb.c:372 mt76u_buf_free()
  warn: address of 'urb->sg[i]' is non-NULL

There is no need to check sg page pointer since urb->num_sgs
has been already validated in mt76u_fill_rx_sg

Fixes: cb83585e1121 ("mt76: usb: fix possible memory leak in mt76u_buf_free")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/usb.c

index 792f5012f1b1acaeb1c8c2e8970fda472095aabd..7cd95f950ca251efc48718b211ecc0a24087bf5d 100644 (file)
@@ -364,16 +364,11 @@ int mt76u_buf_alloc(struct mt76_dev *dev, struct mt76u_buf *buf,
 void mt76u_buf_free(struct mt76u_buf *buf)
 {
        struct urb *urb = buf->urb;
-       struct scatterlist *sg;
        int i;
 
-       for (i = 0; i < urb->num_sgs; i++) {
-               sg = &urb->sg[i];
-               if (!sg)
-                       continue;
+       for (i = 0; i < urb->num_sgs; i++)
+               skb_free_frag(sg_virt(&urb->sg[i]));
 
-               skb_free_frag(sg_virt(sg));
-       }
        if (buf->buf)
                skb_free_frag(buf->buf);