ethtool: fix uninitialized return value
Subsystems (2)
PATCH 1/6 ethtool: fix uninitialized return value
--- ethtool.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
ethtool.c +3 -4
@@ -4723,8 +4723,8 @@ static int do_get_phy_tunable(struct cmd_context *ctx) {int argc = ctx->argc;char **argp = ctx->argp; -int err, i;u8 downshift_changed =0 ; +int i;if (argc <1 )exit_bad_args ();
@@ -4750,8 +4750,7 @@ static int do_get_phy_tunable(struct cmd_context *ctx) cont.ds.id =ETHTOOL_PHY_DOWNSHIFT ; cont.ds.type_id =ETHTOOL_TUNABLE_U8 ; cont.ds.len =1 ; - err =send_ioctl (ctx, &cont.ds); -if (err <0 ) { +if (send_ioctl (ctx, &cont.ds) <0 ) {perror ("Cannot Get PHY downshift count" );return 87 ; }
@@ -4762,7 +4761,7 @@ static int do_get_phy_tunable(struct cmd_context *ctx)fprintf (stdout,"Downshift disabled\n" ); } -return err; +return 0 ; }static __u32 parse_reset (char *val,__u32 bitset,char *arg,__u32 *data)
Signature · 1 line
2.16.4
PATCH 2/6 ethtool: fix RING_VF assignment
--- rxclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
rxclass.c +1 -1
@@ -1066,7 +1066,7 @@ static int rxclass_get_val(char *str, unsigned char *p, u32 *flags, val++; *(u64 *)&p[opt->offset] &= ~ETHTOOL_RX_FLOW_SPEC_RING_VF ; - *(u64 *)&p[opt->offset] = (u64 )val <<ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF ; + *(u64 *)&p[opt->offset] |= (u64 )val <<ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF ;break ; }case OPT_RING_QUEUE : {
Signature · 1 line
2.16.4
PATCH 3/6 ethtool: remove unused global variable
In reply to Ivan Vecera--- sfc.c | 3 --- 1 file changed, 3 deletions(-)
sfc.c +0 -3
@@ -3083,9 +3083,6 @@ static const struct efx_nic_reg_field efx_nic_reg_fields_TX_PACE[] = {REGISTER_FIELD_BZ (TX_PACE_SB_AF ), REGISTER_FIELD_BZ(TX_PACE_SB_NOT_AF), }; -static const struct efx_nic_reg_field efx_nic_reg_fields_TX_PACE_DROP_QID[] = { -REGISTER_FIELD_BZ (TX_PACE_QID_DRP_CNT ), -};static const struct efx_nic_reg_field efx_nic_reg_fields_TX_VLAN[] = {REGISTER_FIELD_BB (TX_VLAN0 ),REGISTER_FIELD_BB (TX_VLAN0_PORT0_EN ),
Signature · 1 line
2.16.4
PATCH 4/6 ethtool: several fixes in do_gregs()
In reply to Ivan Vecera- correctly close gregs_dump_file in case of fstat() failure
- check for error from realloc
--- ethtool.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
ethtool.c +10 -1
@@ -3179,17 +3179,26 @@ static int do_gregs(struct cmd_context *ctx)if (!gregs_dump_raw && gregs_dump_file !=NULL ) {/* overwrite reg values from file dump */ FILE *f =fopen (gregs_dump_file,"r" ); +struct ethtool_regs *nregs;struct stat st;size_t nread;if (!f ||fstat (fileno (f), &st) <0 ) {fprintf (stderr,"Can't open '%s': %s\n" , gregs_dump_file,strerror (errno)); +if (f) +fclose (f);free (regs);return 75 ; } - regs =realloc (regs,sizeof (*regs) + st.st_size); + nregs =realloc (regs,sizeof (*regs) + st.st_size); +if (!nregs) { +perror ("Cannot allocate memory for register dump" ); +free (regs);/* was not freed by realloc */ +return 73 ; + } + regs = nregs; regs->len = st.st_size; nread =fread (regs->data, regs->len,1 , f);fclose (f);
Signature · 1 line
2.16.4
PATCH 5/6 ethtool: correctly free hkey when get_stringset() fails
In reply to Ivan VeceraMemory allocated for 'hkey' is not freed when get_stringset(..., ETH_SS_RSS_HASH_FUNCS...) fails.
--- ethtool.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
ethtool.c +6 -7
@@ -3910,7 +3910,7 @@ static int do_srxfhindir(struct cmd_context *ctx, int rxfhindir_default,static int do_srxfh (struct cmd_context *ctx) {struct ethtool_rxfh rss_head = {0 }; -struct ethtool_rxfh *rss; +struct ethtool_rxfh *rss =NULL ;struct ethtool_rxnfc ring_count;int rxfhindir_equal =0 , rxfhindir_default =0 ;struct ethtool_gstrings *hfuncs =NULL ;
@@ -4064,7 +4064,8 @@ static int do_srxfh(struct cmd_context *ctx) hfuncs =get_stringset (ctx,ETH_SS_RSS_HASH_FUNCS ,0 ,1 );if (!hfuncs) {perror ("Cannot get hash functions names" ); -return 1 ; + err =1 ; + goto free; }for (i =0 ; i < hfuncs->len && !req_hfunc ; i++) {
@@ -4078,8 +4079,8 @@ static int do_srxfh(struct cmd_context *ctx)if (!req_hfunc) {fprintf (stderr,"Unknown hash function: %s\n" , req_hfunc_name); -free (hfuncs); -return 1 ; + err =1 ; + goto free; } }
@@ -4120,9 +4121,7 @@ static int do_srxfh(struct cmd_context *ctx) } free: -if (hkey) -free (hkey); - +free (hkey);free (rss);free (hfuncs);return err;
Signature · 1 line
2.16.4
PATCH 6/6 ethtool: remove unreachable code
In reply to Ivan VeceraThe default switch case is unreachable as the MAX_CHANNEL_NUM == 4.
--- qsfp.c | 3 --- 1 file changed, 3 deletions(-)
qsfp.c +0 -3
@@ -661,9 +661,6 @@ static void sff8636_dom_parse(const __u8 *id, struct sff_diags *sd) tx_power_offset =SFF8636_TX_PWR_4_OFFSET ; tx_bias_offset =SFF8636_TX_BIAS_4_OFFSET ;break ; -default : -printf (" Invalid channel: %d\n" , i); -break ; } sd->scd[i].bias_cur =OFFSET_TO_U16 (tx_bias_offset); sd->scd[i].rx_power =OFFSET_TO_U16 (rx_power_offset);
Signature · 1 line
2.16.4
Re: [PATCH ethtool 5/6] ethtool: correctly free hkey when get_stringset() fails
In reply to Ivan VeceraQuoted 4 lines · Ivan Vecera
Memory allocated for 'hkey' is not freed when
get_stringset(..., ETH_SS_RSS_HASH_FUNCS...)fails.Fixes b888f35 ("ethtool: Support for configurable RSS hash function")
Thanks for fixing this!
Please use the first 12 characters of the sha1 in the Fixes line.
Quoted 52 lines
Cc Gal Pressman <[email protected]>Signed-off-by Ivan Vecera <[email protected]>--- ethtool.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)ethtool.c +6
-7@@ -3910,7 +3910,7 @@ static int do_srxfhindir(struct cmd_context *ctx, int rxfhindir_default,static int do_srxfh (struct cmd_context *ctx) {struct ethtool_rxfh rss_head = {0 }; -struct ethtool_rxfh *rss; +struct ethtool_rxfh *rss =NULL ;struct ethtool_rxnfc ring_count;int rxfhindir_equal =0 , rxfhindir_default =0 ;struct ethtool_gstrings *hfuncs =NULL ;@@ -4064,7 +4064,8 @@ static int do_srxfh(struct cmd_context *ctx) hfuncs =get_stringset (ctx,ETH_SS_RSS_HASH_FUNCS ,0 ,1 );if (!hfuncs) {perror ("Cannot get hash functions names" ); -return 1 ; + err =1 ; + goto free; }for (i =0 ; i < hfuncs->len && !req_hfunc ; i++) {@@ -4078,8 +4079,8 @@ static int do_srxfh(struct cmd_context *ctx)if (!req_hfunc) {fprintf (stderr,"Unknown hash function: %s\n" , req_hfunc_name); -free (hfuncs); -return 1 ; + err =1 ; + goto free; } }@@ -4120,9 +4121,7 @@ static int do_srxfh(struct cmd_context *ctx) } free: -if (hkey) -free (hkey); - +free (hkey);free (rss);free (hfuncs);return err;
RE: [PATCH ethtool 2/6] ethtool: fix RING_VF assignment
In reply to Ivan VeceraQuoted 28 lines
-----Original Message-----
From: Ivan Vecera [mailto:[email protected]]
Sent: Friday, June 08, 2018 2:20 AM
To: [email protected]
Cc: [email protected]; Keller, Jacob E <[email protected]>
Subject: [PATCH ethtool 2/6] ethtool: fixRING_VFassignmentFixes 36ee712 ("ethtool: support queue and VF fields for rxclass filters")Cc Jacob Keller <[email protected]>Signed-off-by Ivan Vecera <[email protected]>--- rxclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)rxclass.c +1
-1@@ -1066,7 +1066,7 @@ static int rxclass_get_val(char *str, unsigned char *p, u32 *flags, val++; *(u64 *)&p[opt->offset] &= ~ETHTOOL_RX_FLOW_SPEC_RING_VF ; - *(u64 *)&p[opt->offset] = (u64 )val <<ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF ; + *(u64 *)&p[opt->offset] |= (u64)val <<
ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF;
rxclass.c
Quoted 2 lines
rxclass.c +0
-0break ; }
Hah. Good catch.
Thanks,
Jake
Quoted 3 lines
case
OPT_RING_QUEUE: {
--
2.16.4
Quoted 2 lines · Ivan Vecera
Fixes b0fe96d ("Ethtool: Implements ETHTOOL_PHY_GTUNABLE/ETHTOOL_PHY_STUNABLE and PHY downshift")Signed-off-by Ivan Vecera <[email protected]>
LGTM -- I have queued the series for the next release, including extending the commit IDs...
Thanks!
John
Signature · 2 lines
John W. Linville Someday the world will need a hero, and you [email protected] might be all we have. Be ready.