* [PATCH 1/1] net: ethernet: qlogic: set error code on failure
@ 2016-12-04 5:53 Pan Bian
2016-12-04 7:29 ` Mintz, Yuval
0 siblings, 1 reply; 3+ messages in thread
From: Pan Bian @ 2016-12-04 5:53 UTC (permalink / raw)
To: Yuval Mintz, Ariel Elior, everest-linux-l2, netdev; +Cc: linux-kernel, Pan Bian
From: Pan Bian <bianpan2016@163.com>
When calling dma_mapping_error(), the value of return variable rc is 0.
And when the call returns an unexpected value, rc is not set to a
negative errno. Thus, it will return 0 on the error path, and its
callers cannot detect the bug. This patch fixes the bug, assigning
"-ENOMEM" to err.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189041
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/net/ethernet/qlogic/qed/qed_ll2.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
index f95385c..62ae55b 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
@@ -1730,6 +1730,7 @@ static int qed_ll2_start_xmit(struct qed_dev *cdev, struct sk_buff *skb)
mapping))) {
DP_NOTICE(cdev,
"Unable to map frag - dropping packet\n");
+ rc = -ENOMEM;
goto err;
}
} else {
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH 1/1] net: ethernet: qlogic: set error code on failure
2016-12-04 5:53 [PATCH 1/1] net: ethernet: qlogic: set error code on failure Pan Bian
@ 2016-12-04 7:29 ` Mintz, Yuval
2016-12-05 19:55 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Mintz, Yuval @ 2016-12-04 7:29 UTC (permalink / raw)
To: Pan Bian, netdev; +Cc: Elior, Ariel
> From: Pan Bian <bianpan2016@163.com>
>
> When calling dma_mapping_error(), the value of return variable rc is 0.
> And when the call returns an unexpected value, rc is not set to a negative
> errno. Thus, it will return 0 on the error path, and its callers cannot detect
> the bug. This patch fixes the bug, assigning "-ENOMEM" to err.
>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189041
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>
The title should have been "[PATCH net 1/1] qed: Set error code on failure".
But the fix itself is sound. Thanks.
BTW, is -ENOMEM the right return code in case of DMA mapping errors?
Acked-by: Yuval Mintz <Yuval.Mintz@cavium.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] net: ethernet: qlogic: set error code on failure
2016-12-04 7:29 ` Mintz, Yuval
@ 2016-12-05 19:55 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2016-12-05 19:55 UTC (permalink / raw)
To: Yuval.Mintz; +Cc: bianpan201603, netdev, Ariel.Elior
From: "Mintz, Yuval" <Yuval.Mintz@cavium.com>
Date: Sun, 4 Dec 2016 07:29:58 +0000
>> From: Pan Bian <bianpan2016@163.com>
>>
>> When calling dma_mapping_error(), the value of return variable rc is 0.
>> And when the call returns an unexpected value, rc is not set to a negative
>> errno. Thus, it will return 0 on the error path, and its callers cannot detect
>> the bug. This patch fixes the bug, assigning "-ENOMEM" to err.
>>
>> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189041
>>
>> Signed-off-by: Pan Bian <bianpan2016@163.com>
>
> The title should have been "[PATCH net 1/1] qed: Set error code on failure".
>
> But the fix itself is sound. Thanks.
> BTW, is -ENOMEM the right return code in case of DMA mapping errors?
>
> Acked-by: Yuval Mintz <Yuval.Mintz@cavium.com>
Applied.
Indeed, -ENOMEM is usually the right thing to use for DMA mapping errors.
Because usually the error is because we're run out of IOMMU resources
or similar. And -ENOMEM is pretty much the error code which maps most
closely to that situation.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-12-05 20:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-04 5:53 [PATCH 1/1] net: ethernet: qlogic: set error code on failure Pan Bian
2016-12-04 7:29 ` Mintz, Yuval
2016-12-05 19:55 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.