* [dpdk-dev] [PATCH] net/ixgbe:fix some bugs about rte zmalloc memory may NULL
@ 2017-08-22 11:49 Rongqiang XIE
2017-08-23 10:36 ` Ferruh Yigit
0 siblings, 1 reply; 3+ messages in thread
From: Rongqiang XIE @ 2017-08-22 11:49 UTC (permalink / raw)
To: wenzhuo.lu; +Cc: dev, Rongqiang XIE
In the function ixgbe_flow_create(), the value ntuple_filter_ptr,
ethertype_filter_ptr,syn_filter_ptr,fdir_rule_ptr and l2_tn_filter_ptr
use rte_zmalloc() malloc memory may return NULL,so, we should
add judge the return is NULL or success.
Signed-off-by: Rongqiang XIE <xie.rongqiang@zte.com.cn>
---
drivers/net/ixgbe/ixgbe_flow.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c
index d679608..c8645f0 100644
--- a/drivers/net/ixgbe/ixgbe_flow.c
+++ b/drivers/net/ixgbe/ixgbe_flow.c
@@ -2707,6 +2707,10 @@ static inline uint8_t signature_match(const struct rte_flow_item pattern[])
if (!ret) {
ntuple_filter_ptr = rte_zmalloc("ixgbe_ntuple_filter",
sizeof(struct ixgbe_ntuple_filter_ele), 0);
+ if (!ntuple_filter_ptr) {
+ PMD_DRV_LOG(ERR, "failed to allocate memory");
+ goto out;
+ }
(void)rte_memcpy(&ntuple_filter_ptr->filter_info,
&ntuple_filter,
sizeof(struct rte_eth_ntuple_filter));
@@ -2729,6 +2733,10 @@ static inline uint8_t signature_match(const struct rte_flow_item pattern[])
ethertype_filter_ptr = rte_zmalloc(
"ixgbe_ethertype_filter",
sizeof(struct ixgbe_ethertype_filter_ele), 0);
+ if (!ethertype_filter_ptr) {
+ PMD_DRV_LOG(ERR, "failed to allocate memory");
+ goto out;
+ }
(void)rte_memcpy(ðertype_filter_ptr->filter_info,
ðertype_filter,
sizeof(struct rte_eth_ethertype_filter));
@@ -2749,6 +2757,10 @@ static inline uint8_t signature_match(const struct rte_flow_item pattern[])
if (!ret) {
syn_filter_ptr = rte_zmalloc("ixgbe_syn_filter",
sizeof(struct ixgbe_eth_syn_filter_ele), 0);
+ if (!syn_filter_ptr) {
+ PMD_DRV_LOG(ERR, "failed to allocate memory");
+ goto out;
+ }
(void)rte_memcpy(&syn_filter_ptr->filter_info,
&syn_filter,
sizeof(struct rte_eth_syn_filter));
@@ -2809,6 +2821,10 @@ static inline uint8_t signature_match(const struct rte_flow_item pattern[])
if (!ret) {
fdir_rule_ptr = rte_zmalloc("ixgbe_fdir_filter",
sizeof(struct ixgbe_fdir_rule_ele), 0);
+ if (!fdir_rule_ptr) {
+ PMD_DRV_LOG(ERR, "failed to allocate memory");
+ goto out;
+ }
(void)rte_memcpy(&fdir_rule_ptr->filter_info,
&fdir_rule,
sizeof(struct ixgbe_fdir_rule));
@@ -2842,6 +2858,10 @@ static inline uint8_t signature_match(const struct rte_flow_item pattern[])
if (!ret) {
l2_tn_filter_ptr = rte_zmalloc("ixgbe_l2_tn_filter",
sizeof(struct ixgbe_eth_l2_tunnel_conf_ele), 0);
+ if (!l2_tn_filter_ptr) {
+ PMD_DRV_LOG(ERR, "failed to allocate memory");
+ goto out;
+ }
(void)rte_memcpy(&l2_tn_filter_ptr->filter_info,
&l2_tn_filter,
sizeof(struct rte_eth_l2_tunnel_conf));
--
1.8.3.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] net/ixgbe:fix some bugs about rte zmalloc memory may NULL
2017-08-22 11:49 [dpdk-dev] [PATCH] net/ixgbe:fix some bugs about rte zmalloc memory may NULL Rongqiang XIE
@ 2017-08-23 10:36 ` Ferruh Yigit
2017-08-23 10:37 ` Ferruh Yigit
0 siblings, 1 reply; 3+ messages in thread
From: Ferruh Yigit @ 2017-08-23 10:36 UTC (permalink / raw)
To: Rongqiang XIE, wenzhuo.lu; +Cc: dev
On 8/22/2017 12:49 PM, Rongqiang XIE wrote:
> In the function ixgbe_flow_create(), the value ntuple_filter_ptr,
> ethertype_filter_ptr,syn_filter_ptr,fdir_rule_ptr and l2_tn_filter_ptr
> use rte_zmalloc() malloc memory may return NULL,so, we should
> add judge the return is NULL or success.
>
> Signed-off-by: Rongqiang XIE <xie.rongqiang@zte.com.cn>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
> drivers/net/ixgbe/ixgbe_flow.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c
> index d679608..c8645f0 100644
> --- a/drivers/net/ixgbe/ixgbe_flow.c
> +++ b/drivers/net/ixgbe/ixgbe_flow.c
> @@ -2707,6 +2707,10 @@ static inline uint8_t signature_match(const struct rte_flow_item pattern[])
> if (!ret) {
> ntuple_filter_ptr = rte_zmalloc("ixgbe_ntuple_filter",
> sizeof(struct ixgbe_ntuple_filter_ele), 0);
> + if (!ntuple_filter_ptr) {
> + PMD_DRV_LOG(ERR, "failed to allocate memory");
> + goto out;
> + }
> (void)rte_memcpy(&ntuple_filter_ptr->filter_info,
> &ntuple_filter,
> sizeof(struct rte_eth_ntuple_filter));
> @@ -2729,6 +2733,10 @@ static inline uint8_t signature_match(const struct rte_flow_item pattern[])
> ethertype_filter_ptr = rte_zmalloc(
> "ixgbe_ethertype_filter",
> sizeof(struct ixgbe_ethertype_filter_ele), 0);
> + if (!ethertype_filter_ptr) {
> + PMD_DRV_LOG(ERR, "failed to allocate memory");
> + goto out;
In out path, these variables should be freed which seems missing, would
you mind another patch to fix this?
> + }
> (void)rte_memcpy(ðertype_filter_ptr->filter_info,
> ðertype_filter,
> sizeof(struct rte_eth_ethertype_filter));
<...>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] net/ixgbe:fix some bugs about rte zmalloc memory may NULL
2017-08-23 10:36 ` Ferruh Yigit
@ 2017-08-23 10:37 ` Ferruh Yigit
0 siblings, 0 replies; 3+ messages in thread
From: Ferruh Yigit @ 2017-08-23 10:37 UTC (permalink / raw)
To: Rongqiang XIE, wenzhuo.lu; +Cc: dev
On 8/23/2017 11:36 AM, Ferruh Yigit wrote:
> On 8/22/2017 12:49 PM, Rongqiang XIE wrote:
>> In the function ixgbe_flow_create(), the value ntuple_filter_ptr,
>> ethertype_filter_ptr,syn_filter_ptr,fdir_rule_ptr and l2_tn_filter_ptr
>> use rte_zmalloc() malloc memory may return NULL,so, we should
>> add judge the return is NULL or success.
>>
>> Signed-off-by: Rongqiang XIE <xie.rongqiang@zte.com.cn>
>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
Applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-23 10:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-22 11:49 [dpdk-dev] [PATCH] net/ixgbe:fix some bugs about rte zmalloc memory may NULL Rongqiang XIE
2017-08-23 10:36 ` Ferruh Yigit
2017-08-23 10:37 ` 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).