Message ID | 1312904711-1855-1-git-send-email-wangshaoyan.pt@taobao.com |
---|---|
State | Superseded, archived |
Delegated to: | David Miller |
Headers | show |
From: stufever@gmail.com Date: Tue, 9 Aug 2011 23:45:11 +0800 > From: Wang Shaoyan <wangshaoyan.pt@taobao.com> > > drivers/net/gianfar_ethtool.c:765: warning: the frame size of 2048 bytes is larger than 1024 bytes > > Signed-off-by: Wang Shaoyan <wangshaoyan.pt@taobao.com> Would you be so kind as to actually acknowledge in some way the person who found all the bugs in your first version of this patch? :-/ -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks for remainding, I just want to cover up my careless asap:-) 2011/8/9 David Miller <davem@davemloft.net>: > From: stufever@gmail.com > Date: Tue, 9 Aug 2011 23:45:11 +0800 > >> From: Wang Shaoyan <wangshaoyan.pt@taobao.com> >> >> drivers/net/gianfar_ethtool.c:765: warning: the frame size of 2048 bytes is larger than 1024 bytes >> >> Signed-off-by: Wang Shaoyan <wangshaoyan.pt@taobao.com> > > Would you be so kind as to actually acknowledge in some way the person > who found all the bugs in your first version of this patch? :-/ > >
On Tue, 2011-08-09 at 23:45 +0800, stufever@gmail.com wrote: > From: Wang Shaoyan <wangshaoyan.pt@taobao.com> > drivers/net/gianfar_ethtool.c:765: warning: the frame size of 2048 bytes is larger than 1024 bytes [] > diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c [] > @@ -686,10 +686,26 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, u > { > unsigned int last_rule_idx = priv->cur_filer_idx; > unsigned int cmp_rqfpr; > - unsigned int local_rqfpr[MAX_FILER_IDX + 1]; > - unsigned int local_rqfcr[MAX_FILER_IDX + 1]; > + unsigned int *local_rqfpr; > + unsigned int *local_rqfcr; > int i = 0x0, k = 0x0; > int j = MAX_FILER_IDX, l = 0x0; > + int ret = 1; > + > + local_rqfpr = kmalloc(sizeof(unsigned int) * (MAX_FILER_IDX + 1), > + GFP_KERNEL); > + if (!local_rqfpr) { > + pr_err("Out of memory\n"); > + ret = 0; > + got err; > + } > + local_rqfcr = kmalloc(sizeof(unsigned int) * (MAX_FILER_IDX + 1), > + GFP_KERNEL); > + if (!local_rqfcr) { > + pr_err("Out of memory\n"); > + ret = 0; > + goto err1; > + } Perhaps it'd be clearer to use: local_rqfpr = kmalloc(...) local_rqfcr = kmalloc(...) if (!local_rqfpr || !local_rqfcr) { pr_err(...) ret = -ENOMEM; goto err; } [...] err: kfree(local_rqfpr); kfree(local_rqfcr); return ret; Is the "local_" prefix useful? It seems like visual noise to me. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
I thought kfree should not call, when kmalloc is failed. Now I think is fine, thanks, it is much clearer > Perhaps it'd be clearer to use: > > local_rqfpr = kmalloc(...) > local_rqfcr = kmalloc(...) > if (!local_rqfpr || !local_rqfcr) { > pr_err(...) > ret = -ENOMEM; > goto err; > } > > [...] > > err: > kfree(local_rqfpr); > kfree(local_rqfcr); > return ret; > > Is the "local_" prefix useful? > It seems like visual noise to me. They are some temporary variable, we better to left them > >
diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c index 6e35069..9bca11c 100644 --- a/drivers/net/gianfar_ethtool.c +++ b/drivers/net/gianfar_ethtool.c @@ -686,10 +686,26 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, u { unsigned int last_rule_idx = priv->cur_filer_idx; unsigned int cmp_rqfpr; - unsigned int local_rqfpr[MAX_FILER_IDX + 1]; - unsigned int local_rqfcr[MAX_FILER_IDX + 1]; + unsigned int *local_rqfpr; + unsigned int *local_rqfcr; int i = 0x0, k = 0x0; int j = MAX_FILER_IDX, l = 0x0; + int ret = 1; + + local_rqfpr = kmalloc(sizeof(unsigned int) * (MAX_FILER_IDX + 1), + GFP_KERNEL); + if (!local_rqfpr) { + pr_err("Out of memory\n"); + ret = 0; + got err; + } + local_rqfcr = kmalloc(sizeof(unsigned int) * (MAX_FILER_IDX + 1), + GFP_KERNEL); + if (!local_rqfcr) { + pr_err("Out of memory\n"); + ret = 0; + goto err1; + } switch (class) { case TCP_V4_FLOW: @@ -765,7 +781,11 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, u priv->cur_filer_idx = priv->cur_filer_idx - 1; } - return 1; + kfree(local_rqfcr); +err1: + kfree(local_rqfpr); +err: + return ret; } static int gfar_set_hash_opts(struct gfar_private *priv, struct ethtool_rxnfc *cmd)