]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: lantiq_xrx200: restore buffer if memory allocation failed
authorAleksander Jan Bajkowski <olek2@wp.pl>
Wed, 24 Aug 2022 21:54:08 +0000 (23:54 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 25 Aug 2022 19:41:39 +0000 (12:41 -0700)
In a situation where memory allocation fails, an invalid buffer address
is stored. When this descriptor is used again, the system panics in the
build_skb() function when accessing memory.

Fixes: 8d70fa671061 ("lantiq: net: fix duplicated skb in rx descriptor ring")
Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/lantiq_xrx200.c

index 25adce7f0c7c04570a106de4797bff3b1aa6641a..57f27cc7724e7b63873b3205e42a08bd3a30a697 100644 (file)
@@ -193,6 +193,7 @@ static int xrx200_alloc_buf(struct xrx200_chan *ch, void *(*alloc)(unsigned int
 
        ch->rx_buff[ch->dma.desc] = alloc(priv->rx_skb_size);
        if (!ch->rx_buff[ch->dma.desc]) {
+               ch->rx_buff[ch->dma.desc] = buf;
                ret = -ENOMEM;
                goto skip;
        }