mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 21:57:43 +00:00
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>
This commit is contained in:
parent
d9ee6015e5
commit
b3b2f62c62
1 changed files with 5 additions and 0 deletions
|
@ -457,6 +457,9 @@ static void mt7601u_free_tx(struct mt7601u_dev *dev)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (!dev->tx_q)
|
||||||
|
return;
|
||||||
|
|
||||||
for (i = 0; i < __MT_EP_OUT_MAX; i++)
|
for (i = 0; i < __MT_EP_OUT_MAX; i++)
|
||||||
mt7601u_free_tx_queue(&dev->tx_q[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,
|
dev->tx_q = devm_kcalloc(dev->dev, __MT_EP_OUT_MAX,
|
||||||
sizeof(*dev->tx_q), GFP_KERNEL);
|
sizeof(*dev->tx_q), GFP_KERNEL);
|
||||||
|
if (!dev->tx_q)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
for (i = 0; i < __MT_EP_OUT_MAX; i++)
|
for (i = 0; i < __MT_EP_OUT_MAX; i++)
|
||||||
if (mt7601u_alloc_tx_queue(dev, &dev->tx_q[i]))
|
if (mt7601u_alloc_tx_queue(dev, &dev->tx_q[i]))
|
||||||
|
|
Loading…
Reference in a new issue