diff options
author | Christophe Jaillet <christophe.jaillet@wanadoo.fr> | 2017-08-22 01:06:17 +0300 |
---|---|---|
committer | Kalle Valo <kvalo@codeaurora.org> | 2017-08-24 12:54:33 +0300 |
commit | b3b2f62c6238808f74e00767a3224f9be54d606f (patch) | |
tree | 51ed02119ee7bb77507b16cd31a08836c98bc60d /drivers/net/wireless/mediatek/mt7601u/dma.c | |
parent | d9ee6015e573176e599693b6d0125ad74b210623 (diff) | |
download | linux-b3b2f62c6238808f74e00767a3224f9be54d606f.tar.xz |
mt7601u: check memory allocation failure
Check memory allocation failure and return -ENOMEM in such a case, as
already done a few lines below.
As 'dev->tx_q' can be NULL, we also need to check for that in
'mt7601u_free_tx()', and return early.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/net/wireless/mediatek/mt7601u/dma.c')
-rw-r--r-- | drivers/net/wireless/mediatek/mt7601u/dma.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/net/wireless/mediatek/mt7601u/dma.c b/drivers/net/wireless/mediatek/mt7601u/dma.c index 660267b359e4..7f3e3983b781 100644 --- a/drivers/net/wireless/mediatek/mt7601u/dma.c +++ b/drivers/net/wireless/mediatek/mt7601u/dma.c @@ -457,6 +457,9 @@ static void mt7601u_free_tx(struct mt7601u_dev *dev) { int i; + if (!dev->tx_q) + return; + for (i = 0; i < __MT_EP_OUT_MAX; i++) mt7601u_free_tx_queue(&dev->tx_q[i]); } @@ -484,6 +487,8 @@ static int mt7601u_alloc_tx(struct mt7601u_dev *dev) dev->tx_q = devm_kcalloc(dev->dev, __MT_EP_OUT_MAX, sizeof(*dev->tx_q), GFP_KERNEL); + if (!dev->tx_q) + return -ENOMEM; for (i = 0; i < __MT_EP_OUT_MAX; i++) if (mt7601u_alloc_tx_queue(dev, &dev->tx_q[i])) |