mana_create_rxq() returns a struct mana_rxq pointer and returns NULL on any failure. The caller, mana_add_rx_queues(), cannot tell what went wrong and hardcodes the error as -ENOMEM. As a result the actual failure reported by the lower layers (for example -EPROTO from a failed HW request) is masked and every RX queue creation failure looks like an out-of-memory error. Return an ERR_PTR() encoded error code from mana_create_rxq() on failure instead of NULL. The caller now propagates the returned error code directly instead of substituting -ENOMEM.
Unified · Split
| @@ -2829,7 +2829,7 @@ static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc, · 2828 unmodified lines | |||
| 2829 | 2829 | ||
| 2830 | rxq = kvzalloc_flex(*rxq, rx_oobs, apc->rx_queue_size); | 2830 | rxq = kvzalloc_flex(*rxq, rx_oobs, apc->rx_queue_size); |
| 2831 | if (!rxq) | 2831 | if (!rxq) |
| 2832 | return NULL; | 2832 | return ERR_PTR(-ENOMEM); |
| 2833 | 2833 | ||
| 2834 | rxq->ndev = ndev; | 2834 | rxq->ndev = ndev; |
| 2835 | rxq->num_rx_buf = apc->rx_queue_size; | 2835 | rxq->num_rx_buf = apc->rx_queue_size; |
| @@ -2930,7 +2930,7 @@ out: · 94 unmodified lines | |||
| 2930 | 2930 | ||
| 2931 | mana_destroy_rxq(apc, rxq, false); | 2931 | mana_destroy_rxq(apc, rxq, false); |
| 2932 | 2932 | ||
| 2933 | return NULL; | 2933 | return ERR_PTR(err); |
| 2934 | } | 2934 | } |
| 2935 | 2935 | ||
| 2936 | static void mana_create_rxq_debugfs(struct mana_port_context *apc, int idx) | 2936 | static void mana_create_rxq_debugfs(struct mana_port_context *apc, int idx) |
| @@ -2964,8 +2964,8 @@ static int mana_add_rx_queues(struct mana_port_context *apc, · 27 unmodified lines | |||
| 2964 | 2964 | ||
| 2965 | for (i = 0; i < apc->num_queues; i++) { | 2965 | for (i = 0; i < apc->num_queues; i++) { |
| 2966 | rxq = mana_create_rxq(apc, i, &apc->eqs[i], ndev); | 2966 | rxq = mana_create_rxq(apc, i, &apc->eqs[i], ndev); |
| 2967 | if (!rxq) { | 2967 | if (IS_ERR(rxq)) { |
| 2968 | err = -ENOMEM; | 2968 | err = PTR_ERR(rxq); |
| 2969 | netdev_err(ndev, "Failed to create rxq %d : %d\n", i, err); | 2969 | netdev_err(ndev, "Failed to create rxq %d : %d\n", i, err); |
| 2970 | goto out; | 2970 | goto out; |
| 2971 | } | 2971 | } |