History

net: mana: Return error code from mana_create_rxq()

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.

Aditya Garg committed 3 months ago

Commit e67cc801 parent 4107af91 file · +4 −4Browse files

Unified · Split

drivers/net/ethernet/microsoft/mana/mana_en.c+4−4
@@ -2829,7 +2829,7 @@ static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc, · 2828 unmodified lines
28292829
28302830 rxq = kvzalloc_flex(*rxq, rx_oobs, apc->rx_queue_size);
28312831 if (!rxq)
2832− return NULL;
2832+ return ERR_PTR(-ENOMEM);
28332833
28342834 rxq->ndev = ndev;
28352835 rxq->num_rx_buf = apc->rx_queue_size;
@@ -2930,7 +2930,7 @@ out: · 94 unmodified lines
29302930
29312931 mana_destroy_rxq(apc, rxq, false);
29322932
2933− return NULL;
2933+ return ERR_PTR(err);
29342934 }
29352935
29362936 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
29642964
29652965 for (i = 0; i < apc->num_queues; i++) {
29662966 rxq = mana_create_rxq(apc, i, &apc->eqs[i], ndev);
2967− if (!rxq) {
2968− err = -ENOMEM;
2967+ if (IS_ERR(rxq)) {
2968+ err = PTR_ERR(rxq);
29692969 netdev_err(ndev, "Failed to create rxq %d : %d\n", i, err);
29702970 goto out;
29712971 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t