Re: [PATCH] wan: dscc4: add checks for dma mapping errors
From: David Miller
Date: Mon Aug 07 2017 - 17:06:46 EST
From: Alexey Khoroshilov <khoroshilov@xxxxxxxxx>
Date: Fri, 4 Aug 2017 23:23:24 +0300
> The driver does not check if mapping dma memory succeed.
> The patch adds the checks and failure handling.
> Found by Linux Driver Verification project (linuxtesting.org).
> Signed-off-by: Alexey Khoroshilov <khoroshilov@xxxxxxxxx>
This is a great example of why it can be irritating to see these
mechanical "bug fixes" for drivers very few people use and actually
test, which introduces new bugs.
> @@ -522,19 +522,27 @@ static inline int try_get_rx_skb(struct dscc4_dev_priv *dpriv,
> struct RxFD *rx_fd = dpriv->rx_fd + dirty;
> const int len = RX_MAX(HDLC_MAX_MRU);
> struct sk_buff *skb;
> - int ret = 0;
> + dma_addr_t addr;
> skb = dev_alloc_skb(len);
> dpriv->rx_skbuff[dirty] = skb;
skb recorded here.
> + dev_kfree_skb_any(skb);
Yet freed here in the error path.
dpriv->rx_skbuff[dirty] should not be set to 'skb' until all possibile
failure tests have passed.