Commit d8c28693 authored by Quentin Deslandes's avatar Quentin Deslandes Committed by Greg Kroah-Hartman

staging: vt6656: use meaningful error code during buffer allocation

Check on called function's returned value for error and return 0 on
success or a negative errno value on error instead of a boolean value.
Signed-off-by: default avatarQuentin Deslandes <quentin.deslandes@itdev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cc81234a
......@@ -405,16 +405,19 @@ static void vnt_free_int_bufs(struct vnt_private *priv)
kfree(priv->int_buf.data_buf);
}
static bool vnt_alloc_bufs(struct vnt_private *priv)
static int vnt_alloc_bufs(struct vnt_private *priv)
{
int ret = 0;
struct vnt_usb_send_context *tx_context;
struct vnt_rcb *rcb;
int ii;
for (ii = 0; ii < priv->num_tx_context; ii++) {
tx_context = kmalloc(sizeof(*tx_context), GFP_KERNEL);
if (!tx_context)
if (!tx_context) {
ret = -ENOMEM;
goto free_tx;
}
priv->tx_context[ii] = tx_context;
tx_context->priv = priv;
......@@ -422,16 +425,20 @@ static bool vnt_alloc_bufs(struct vnt_private *priv)
/* allocate URBs */
tx_context->urb = usb_alloc_urb(0, GFP_KERNEL);
if (!tx_context->urb)
if (!tx_context->urb) {
ret = -ENOMEM;
goto free_tx;
}
tx_context->in_use = false;
}
for (ii = 0; ii < priv->num_rcb; ii++) {
priv->rcb[ii] = kzalloc(sizeof(*priv->rcb[ii]), GFP_KERNEL);
if (!priv->rcb[ii])
if (!priv->rcb[ii]) {
ret = -ENOMEM;
goto free_rx_tx;
}
rcb = priv->rcb[ii];
......@@ -439,39 +446,46 @@ static bool vnt_alloc_bufs(struct vnt_private *priv)
/* allocate URBs */
rcb->urb = usb_alloc_urb(0, GFP_KERNEL);
if (!rcb->urb)
if (!rcb->urb) {
ret = -ENOMEM;
goto free_rx_tx;
}
rcb->skb = dev_alloc_skb(priv->rx_buf_sz);
if (!rcb->skb)
if (!rcb->skb) {
ret = -ENOMEM;
goto free_rx_tx;
}
rcb->in_use = false;
/* submit rx urb */
if (vnt_submit_rx_urb(priv, rcb))
ret = vnt_submit_rx_urb(priv, rcb);
if (ret)
goto free_rx_tx;
}
priv->interrupt_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!priv->interrupt_urb)
if (!priv->interrupt_urb) {
ret = -ENOMEM;
goto free_rx_tx;
}
priv->int_buf.data_buf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL);
if (!priv->int_buf.data_buf) {
usb_free_urb(priv->interrupt_urb);
goto free_rx_tx;
ret = -ENOMEM;
goto free_rx_tx_urb;
}
return true;
return 0;
free_rx_tx_urb:
usb_free_urb(priv->interrupt_urb);
free_rx_tx:
vnt_free_rx_bufs(priv);
free_tx:
vnt_free_tx_bufs(priv);
return false;
return ret;
}
static void vnt_tx_80211(struct ieee80211_hw *hw,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment