Message ID | 20221020033425.11471-1-xiaolinkui@126.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | i40e: add a fault tolerance judgment | expand |
On 10/19/2022 8:34 PM, xiaolinkui wrote: > From: Linkui Xiao <xiaolinkui@kylinos.cn> > > Avoid requesting memory when system memory resources are insufficient. > Reference function i40e_setup_tx_descriptors, adding fault tolerance > handling. > > Signed-off-by: Linkui Xiao <xiaolinkui@kylinos.cn> > --- > drivers/net/ethernet/intel/i40e/i40e_txrx.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c > index d4226161a3ef..673f2f0d078f 100644 > --- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c > +++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c > @@ -1565,6 +1565,9 @@ int i40e_setup_rx_descriptors(struct i40e_ring *rx_ring) > struct device *dev = rx_ring->dev; > int err; > > + if (!dev) > + return -ENOMEM; > + What is this trying to protect against? When does a ring not have a dev pointer? This seems more like patching over a buggy setup where we failed to assign a device pointer. How does this protect against use of system memory resources? It also doesn't seem like it would significantly improve fault tolerance since its possible to have a non-NULL but invalid dev pointer... Thanks, Jake > u64_stats_init(&rx_ring->syncp); > > /* Round up to nearest 4K */
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c index d4226161a3ef..673f2f0d078f 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c +++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c @@ -1565,6 +1565,9 @@ int i40e_setup_rx_descriptors(struct i40e_ring *rx_ring) struct device *dev = rx_ring->dev; int err; + if (!dev) + return -ENOMEM; + u64_stats_init(&rx_ring->syncp); /* Round up to nearest 4K */