All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH net 5/8] iavf: prevent accidental free of filter structure
Date: Fri,  4 Jun 2021 09:48:57 -0700	[thread overview]
Message-ID: <20210604164900.33156-5-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20210604164900.33156-1-anthony.l.nguyen@intel.com>

From: Jacob Keller <jacob.e.keller@intel.com>

In iavf_config_clsflower, the filter structure could be accidentally
released at the end, if iavf_parse_cls_flower or iavf_handle_tclass ever
return a non-zero but positive value.

In this case, the function continues through to the end, and will call
kfree() on the filter structure even though it has been added to the
linked list.

This can actually happen because iavf_parse_cls_flower will return
a positive IAVF_ERR_CONFIG value instead of the traditional negative
error codes.

Fix this by ensuring that the kfree() check and error checks are
similar. Use the more idiomatic "if (err)" to catch all non-zero error
codes.

Fixes: 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index ffffb6e0a6c1..bb533e9781ee 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -3040,11 +3040,11 @@ static int iavf_configure_clsflower(struct iavf_adapter *adapter,
 	/* start out with flow type and eth type IPv4 to begin with */
 	filter->f.flow_type = VIRTCHNL_TCP_V4_FLOW;
 	err = iavf_parse_cls_flower(adapter, cls_flower, filter);
-	if (err < 0)
+	if (err)
 		goto err;
 
 	err = iavf_handle_tclass(adapter, tc, filter);
-	if (err < 0)
+	if (err)
 		goto err;
 
 	/* add filter to the list */
-- 
2.20.1


  parent reply	other threads:[~2021-06-04 16:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-04 16:48 [Intel-wired-lan] [PATCH net 1/8] iavf: check for null in iavf_fix_features Tony Nguyen
2021-06-04 16:48 ` [Intel-wired-lan] [PATCH net 2/8] iavf: free q_vectors before queues in iavf_disable_vf Tony Nguyen
2021-11-01 23:04   ` Brelinski, Tony
2021-06-04 16:48 ` [Intel-wired-lan] [PATCH net 3/8] iavf: don't clear a lock we don't hold Tony Nguyen
2021-11-01 23:03   ` Brelinski, Tony
2021-06-04 16:48 ` [Intel-wired-lan] [PATCH net 4/8] iavf: Fix failure to exit out from last all-multicast mode Tony Nguyen
2021-11-01 23:03   ` Brelinski, Tony
2021-06-04 16:48 ` Tony Nguyen [this message]
2021-11-01 23:02   ` [Intel-wired-lan] [PATCH net 5/8] iavf: prevent accidental free of filter structure Brelinski, Tony
2021-06-04 16:48 ` [Intel-wired-lan] [PATCH net 6/8] iavf: validate pointers Tony Nguyen
2021-11-01 23:02   ` Brelinski, Tony
2021-06-04 16:48 ` [Intel-wired-lan] [PATCH net 7/8] iavf: Fix for the false positive ASQ/ARQ errors while issuing VF reset Tony Nguyen
2021-11-01 23:05   ` Brelinski, Tony
2021-06-04 16:49 ` [Intel-wired-lan] [PATCH net 8/8] iavf: Fix for setting queues to 0 Tony Nguyen
2021-11-01 23:01   ` Brelinski, Tony
2021-11-01 23:04 ` [Intel-wired-lan] [PATCH net 1/8] iavf: check for null in iavf_fix_features Brelinski, Tony

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210604164900.33156-5-anthony.l.nguyen@intel.com \
    --to=anthony.l.nguyen@intel.com \
    --cc=intel-wired-lan@osuosl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.