* [PATCH net] net: hns: fix return value check in __lb_other_process()
@ 2020-12-25 10:35 wangyunjian
2020-12-26 6:38 ` Yonglong Liu
0 siblings, 1 reply; 3+ messages in thread
From: wangyunjian @ 2020-12-25 10:35 UTC (permalink / raw)
To: netdev; +Cc: yisen.zhuang, salil.mehta, jerry.lilijun, xudingke, Yunjian Wang
From: Yunjian Wang <wangyunjian@huawei.com>
The function skb_copy() could return NULL, the return value
need to be checked.
Fixes: b5996f11ea54 ("net: add Hisilicon Network Subsystem basic ethernet support")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
index 7165da0ee9aa..ad18f0e20a23 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
@@ -415,6 +415,10 @@ static void __lb_other_process(struct hns_nic_ring_data *ring_data,
/* for mutl buffer*/
new_skb = skb_copy(skb, GFP_ATOMIC);
dev_kfree_skb_any(skb);
+ if (!new_skb) {
+ ndev->stats.rx_dropped++;
+ return;
+ }
skb = new_skb;
check_ok = 0;
--
2.23.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: hns: fix return value check in __lb_other_process()
2020-12-25 10:35 [PATCH net] net: hns: fix return value check in __lb_other_process() wangyunjian
@ 2020-12-26 6:38 ` Yonglong Liu
2020-12-26 7:54 ` wangyunjian
0 siblings, 1 reply; 3+ messages in thread
From: Yonglong Liu @ 2020-12-26 6:38 UTC (permalink / raw)
To: wangyunjian, netdev; +Cc: yisen.zhuang, salil.mehta, jerry.lilijun, xudingke
On 2020/12/25 18:35, wangyunjian wrote:
> From: Yunjian Wang <wangyunjian@huawei.com>
>
> The function skb_copy() could return NULL, the return value
> need to be checked.
>
> Fixes: b5996f11ea54 ("net: add Hisilicon Network Subsystem basic ethernet support")
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
> drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> index 7165da0ee9aa..ad18f0e20a23 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> @@ -415,6 +415,10 @@ static void __lb_other_process(struct hns_nic_ring_data *ring_data,
> /* for mutl buffer*/
> new_skb = skb_copy(skb, GFP_ATOMIC);
> dev_kfree_skb_any(skb);
> + if (!new_skb) {
> + ndev->stats.rx_dropped++;
You can add a new drop type to ring->states, and then add it to
ndev->stats.rx_dropped,
then you can know that the rx_dropped is from skb_copy() failed.
This process is from self-test, maybe you can just add a error message
rather than increase
the ndev->stats.rx_dropped.
> + return;
> + }
> skb = new_skb;
>
> check_ok = 0;
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH net] net: hns: fix return value check in __lb_other_process()
2020-12-26 6:38 ` Yonglong Liu
@ 2020-12-26 7:54 ` wangyunjian
0 siblings, 0 replies; 3+ messages in thread
From: wangyunjian @ 2020-12-26 7:54 UTC (permalink / raw)
To: liuyonglong, netdev
Cc: Zhuangyuzeng (Yisen), Salil Mehta, Lilijun (Jerry), xudingke
> -----Original Message-----
> From: liuyonglong
> Sent: Saturday, December 26, 2020 2:39 PM
> To: wangyunjian <wangyunjian@huawei.com>; netdev@vger.kernel.org
> Cc: Zhuangyuzeng (Yisen) <yisen.zhuang@huawei.com>; Salil Mehta
> <salil.mehta@huawei.com>; Lilijun (Jerry) <jerry.lilijun@huawei.com>;
> xudingke <xudingke@huawei.com>
> Subject: Re: [PATCH net] net: hns: fix return value check in
> __lb_other_process()
>
>
> On 2020/12/25 18:35, wangyunjian wrote:
> > From: Yunjian Wang <wangyunjian@huawei.com>
> >
> > The function skb_copy() could return NULL, the return value need to be
> > checked.
> >
> > Fixes: b5996f11ea54 ("net: add Hisilicon Network Subsystem basic
> > ethernet support")
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > ---
> > drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> > b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> > index 7165da0ee9aa..ad18f0e20a23 100644
> > --- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> > +++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> > @@ -415,6 +415,10 @@ static void __lb_other_process(struct
> hns_nic_ring_data *ring_data,
> > /* for mutl buffer*/
> > new_skb = skb_copy(skb, GFP_ATOMIC);
> > dev_kfree_skb_any(skb);
> > + if (!new_skb) {
>
> > + ndev->stats.rx_dropped++;
> You can add a new drop type to ring->states, and then add it to
> ndev->stats.rx_dropped,
>
> then you can know that the rx_dropped is from skb_copy() failed.
>
> This process is from self-test, maybe you can just add a error message rather
> than increase
Thanks for your suggestion, I will update it in next version.
>
> the ndev->stats.rx_dropped.
>
>
> > + return;
> > + }
> > skb = new_skb;
> >
> > check_ok = 0;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-26 7:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-25 10:35 [PATCH net] net: hns: fix return value check in __lb_other_process() wangyunjian
2020-12-26 6:38 ` Yonglong Liu
2020-12-26 7:54 ` wangyunjian
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.