DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/enic: fix possible uninitialized variable
@ 2018-12-22 12:41 Haiyang Tan
  2019-01-02 18:02 ` Ferruh Yigit
  0 siblings, 1 reply; 2+ messages in thread
From: Haiyang Tan @ 2018-12-22 12:41 UTC (permalink / raw)
  To: John Daley, Hyong Youb Kim; +Cc: dev, Haiyang Tan

The uninitialized field 'extra_flag' of hash parameter may enable
certain feature silently. Typically, if bit0 of 'extra_flag' set, the
hardware transactional memory support will be enabled unexpectedly.

Signed-off-by: Haiyang Tan <haiyangtan@tencent.com>
---
 drivers/net/enic/enic_clsf.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/net/enic/enic_clsf.c b/drivers/net/enic/enic_clsf.c
index 9d95201ec..f9707c78f 100644
--- a/drivers/net/enic/enic_clsf.c
+++ b/drivers/net/enic/enic_clsf.c
@@ -475,14 +475,15 @@ void enic_clsf_destroy(struct enic *enic)
 int enic_clsf_init(struct enic *enic)
 {
 	char clsf_name[RTE_HASH_NAMESIZE];
-	struct rte_hash_parameters hash_params = {
-		.name = clsf_name,
-		.entries = ENICPMD_CLSF_HASH_ENTRIES,
-		.key_len = sizeof(struct rte_eth_fdir_filter),
-		.hash_func = DEFAULT_HASH_FUNC,
-		.hash_func_init_val = 0,
-		.socket_id = SOCKET_ID_ANY,
-	};
+	struct rte_hash_parameters hash_params = { 0 };
+
+	hash_params.name = clsf_name;
+	hash_params.entries = ENICPMD_CLSF_HASH_ENTRIES;
+	hash_params.key_len = sizeof(struct rte_eth_fdir_filter);
+	hash_params.hash_func = DEFAULT_HASH_FUNC;
+	hash_params.hash_func_init_val = 0;
+	hash_params.socket_id = SOCKET_ID_ANY;
+
 	snprintf(clsf_name, RTE_HASH_NAMESIZE, "enic_clsf_%s", enic->bdf_name);
 	enic->fdir.hash = rte_hash_create(&hash_params);
 	memset(&enic->fdir.stats, 0, sizeof(enic->fdir.stats));
-- 
2.14.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] net/enic: fix possible uninitialized variable
  2018-12-22 12:41 [dpdk-dev] [PATCH] net/enic: fix possible uninitialized variable Haiyang Tan
@ 2019-01-02 18:02 ` Ferruh Yigit
  0 siblings, 0 replies; 2+ messages in thread
From: Ferruh Yigit @ 2019-01-02 18:02 UTC (permalink / raw)
  To: Haiyang Tan, John Daley, Hyong Youb Kim; +Cc: dev

On 12/22/2018 12:41 PM, Haiyang Tan wrote:
> The uninitialized field 'extra_flag' of hash parameter may enable
> certain feature silently. Typically, if bit0 of 'extra_flag' set, the
> hardware transactional memory support will be enabled unexpectedly.
> 
> Signed-off-by: Haiyang Tan <haiyangtan@tencent.com>
> ---
>  drivers/net/enic/enic_clsf.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/enic/enic_clsf.c b/drivers/net/enic/enic_clsf.c
> index 9d95201ec..f9707c78f 100644
> --- a/drivers/net/enic/enic_clsf.c
> +++ b/drivers/net/enic/enic_clsf.c
> @@ -475,14 +475,15 @@ void enic_clsf_destroy(struct enic *enic)
>  int enic_clsf_init(struct enic *enic)
>  {
>  	char clsf_name[RTE_HASH_NAMESIZE];
> -	struct rte_hash_parameters hash_params = {
> -		.name = clsf_name,
> -		.entries = ENICPMD_CLSF_HASH_ENTRIES,
> -		.key_len = sizeof(struct rte_eth_fdir_filter),
> -		.hash_func = DEFAULT_HASH_FUNC,
> -		.hash_func_init_val = 0,
> -		.socket_id = SOCKET_ID_ANY,
> -	};
> +	struct rte_hash_parameters hash_params = { 0 };
> +
> +	hash_params.name = clsf_name;
> +	hash_params.entries = ENICPMD_CLSF_HASH_ENTRIES;
> +	hash_params.key_len = sizeof(struct rte_eth_fdir_filter);
> +	hash_params.hash_func = DEFAULT_HASH_FUNC;
> +	hash_params.hash_func_init_val = 0;
> +	hash_params.socket_id = SOCKET_ID_ANY;

Both code should be doing same thing, since unassigned values are set to 0 by
default, and 'extra_flag' should be already set to zero with old code.

There are a few patches for same thing, I am updating all as 'Rejected', please
shout if I am missing something here.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-02 18:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-22 12:41 [dpdk-dev] [PATCH] net/enic: fix possible uninitialized variable Haiyang Tan
2019-01-02 18:02 ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).