From: Ivan Vecera <ivecera@redhat.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH net] ice: Protect vf_state check by cfg_lock in ice_vc_process_vf_msg()
Date: Sat, 16 Apr 2022 13:30:43 +0200 [thread overview]
Message-ID: <20220416133043.08b4ee74@ceranb> (raw)
In-Reply-To: <248da3d7-cb00-14b6-12f0-6bb9fda6d532@intel.com>
On Fri, 15 Apr 2022 13:55:06 -0700
Tony Nguyen <anthony.l.nguyen@intel.com> wrote:
> >>> diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl.c b/drivers/net/ethernet/intel/ice/ice_virtchnl.c
> >>> index 5612c032f15a..553287a75b50 100644
> >>> --- a/drivers/net/ethernet/intel/ice/ice_virtchnl.c
> >>> +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl.c
> >>> @@ -3625,44 +3625,39 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event)
> >>> return;
> >>> }
> >>>
> >>> + mutex_lock(&vf->cfg_lock);
> >>> +
> >>> /* Check if VF is disabled. */
> >>> if (test_bit(ICE_VF_STATE_DIS, vf->vf_states)) {
> >>> err = -EPERM;
> >>> - goto error_handler;
> >>> - }
> >>> -
> >>> - ops = vf->virtchnl_ops;
> >>> -
> >>> - /* Perform basic checks on the msg */
> >>> - err = virtchnl_vc_validate_vf_msg(&vf->vf_ver, v_opcode, msg, msglen);
> >>> - if (err) {
> >>> - if (err == VIRTCHNL_STATUS_ERR_PARAM)
> >>> - err = -EPERM;
> >>> - else
> >>> - err = -EINVAL;
> >>> + } else {
> >>> + /* Perform basic checks on the msg */
> >>> + err = virtchnl_vc_validate_vf_msg(&vf->vf_ver, v_opcode, msg,
> >>> + msglen);
> >>> + if (err) {
> >>> + if (err == VIRTCHNL_STATUS_ERR_PARAM)
> >>> + err = -EPERM;
> >>> + else
> >>> + err = -EINVAL;
> >>> + }
> >> The chunk above feels a bit like unnecessary churn, no?
> >> Couldn't this patch be simply focused only on extending critical section?
>
> Agree, this doesn't seem related to the fix.
>
> Thanks,
>
> Tony
Yes, it is not directly related but it's just a conversion of following snippet
to avoid ugly and unnecessary 'goto':
if (A) {
err = ...
goto error_handler;
}
if (B) {
err = ...
...
}
if (err) {
...
}
to
if (A) {
err = ...
} else {
if (B) {
...
}
}
if (err) {
...
}
If you want to leave the code as is and remove this from the patch
let me know and I will send v2.
Thanks,
Ivan
WARNING: multiple messages have this Message-ID (diff)
From: Ivan Vecera <ivecera@redhat.com>
To: Tony Nguyen <anthony.l.nguyen@intel.com>
Cc: Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
Fei Liu <feliu@redhat.com>, <netdev@vger.kernel.org>,
<mschmidt@redhat.com>, Brett Creeley <brett@pensando.io>,
open list <linux-kernel@vger.kernel.org>,
"moderated list:INTEL ETHERNET DRIVERS"
<intel-wired-lan@lists.osuosl.org>,
Jakub Kicinski <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"David S. Miller" <davem@davemloft.net>
Subject: Re: [Intel-wired-lan] [PATCH net] ice: Protect vf_state check by cfg_lock in ice_vc_process_vf_msg()
Date: Sat, 16 Apr 2022 13:30:43 +0200 [thread overview]
Message-ID: <20220416133043.08b4ee74@ceranb> (raw)
In-Reply-To: <248da3d7-cb00-14b6-12f0-6bb9fda6d532@intel.com>
On Fri, 15 Apr 2022 13:55:06 -0700
Tony Nguyen <anthony.l.nguyen@intel.com> wrote:
> >>> diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl.c b/drivers/net/ethernet/intel/ice/ice_virtchnl.c
> >>> index 5612c032f15a..553287a75b50 100644
> >>> --- a/drivers/net/ethernet/intel/ice/ice_virtchnl.c
> >>> +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl.c
> >>> @@ -3625,44 +3625,39 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event)
> >>> return;
> >>> }
> >>>
> >>> + mutex_lock(&vf->cfg_lock);
> >>> +
> >>> /* Check if VF is disabled. */
> >>> if (test_bit(ICE_VF_STATE_DIS, vf->vf_states)) {
> >>> err = -EPERM;
> >>> - goto error_handler;
> >>> - }
> >>> -
> >>> - ops = vf->virtchnl_ops;
> >>> -
> >>> - /* Perform basic checks on the msg */
> >>> - err = virtchnl_vc_validate_vf_msg(&vf->vf_ver, v_opcode, msg, msglen);
> >>> - if (err) {
> >>> - if (err == VIRTCHNL_STATUS_ERR_PARAM)
> >>> - err = -EPERM;
> >>> - else
> >>> - err = -EINVAL;
> >>> + } else {
> >>> + /* Perform basic checks on the msg */
> >>> + err = virtchnl_vc_validate_vf_msg(&vf->vf_ver, v_opcode, msg,
> >>> + msglen);
> >>> + if (err) {
> >>> + if (err == VIRTCHNL_STATUS_ERR_PARAM)
> >>> + err = -EPERM;
> >>> + else
> >>> + err = -EINVAL;
> >>> + }
> >> The chunk above feels a bit like unnecessary churn, no?
> >> Couldn't this patch be simply focused only on extending critical section?
>
> Agree, this doesn't seem related to the fix.
>
> Thanks,
>
> Tony
Yes, it is not directly related but it's just a conversion of following snippet
to avoid ugly and unnecessary 'goto':
if (A) {
err = ...
goto error_handler;
}
if (B) {
err = ...
...
}
if (err) {
...
}
to
if (A) {
err = ...
} else {
if (B) {
...
}
}
if (err) {
...
}
If you want to leave the code as is and remove this from the patch
let me know and I will send v2.
Thanks,
Ivan
next prev parent reply other threads:[~2022-04-16 11:30 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-13 7:22 [Intel-wired-lan] [PATCH net] ice: Protect vf_state check by cfg_lock in ice_vc_process_vf_msg() Ivan Vecera
2022-04-13 7:22 ` Ivan Vecera
2022-04-15 11:55 ` [Intel-wired-lan] " Maciej Fijalkowski
2022-04-15 11:55 ` Maciej Fijalkowski
2022-04-15 11:57 ` Maciej Fijalkowski
2022-04-15 11:57 ` Maciej Fijalkowski
2022-04-15 13:53 ` Alexander Lobakin
2022-04-15 13:53 ` Alexander Lobakin
2022-04-15 20:55 ` Tony Nguyen
2022-04-15 20:55 ` Tony Nguyen
2022-04-16 11:30 ` Ivan Vecera [this message]
2022-04-16 11:30 ` Ivan Vecera
2022-04-18 18:10 ` Tony Nguyen
2022-04-18 18:10 ` Tony Nguyen
2022-04-19 14:23 ` Ivan Vecera
2022-04-19 14:23 ` Ivan Vecera
2022-04-15 16:38 ` Ivan Vecera
2022-04-15 16:38 ` Ivan Vecera
2022-04-15 18:31 ` Keller, Jacob E
2022-04-15 18:31 ` Keller, Jacob E
2022-04-15 20:53 ` Tony Nguyen
2022-04-15 20:53 ` Tony Nguyen
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=20220416133043.08b4ee74@ceranb \
--to=ivecera@redhat.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.