From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nguyen, Anthony L Date: Tue, 25 Jan 2022 00:42:47 +0000 Subject: [Intel-wired-lan] [PATCH net-next v1] iavf: Fix incorrect use of assigning iavf_status to int In-Reply-To: <20220121095512.20266-1-mateusz.palczewski@intel.com> References: <20220121095512.20266-1-mateusz.palczewski@intel.com> Message-ID: <5332e7b8df740820a9b16af9bcee94e8d92ec4b4.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: intel-wired-lan@osuosl.org List-ID: On Fri, 2022-01-21 at 10:55 +0100, Mateusz Palczewski wrote: > @@ -65,55 +98,28 @@ int iavf_send_api_ver(struct iavf_adapter > *adapter) > ? **/ > ?int iavf_verify_api_ver(struct iavf_adapter *adapter) > ?{ > -???????struct virtchnl_version_info *pf_vvi; > -???????struct iavf_hw *hw = &adapter->hw; > ????????struct iavf_arq_event_info event; > -???????enum virtchnl_ops op; > -???????enum iavf_status err; > +???????int err; > ? > ????????event.buf_len = IAVF_MAX_AQ_BUF_SIZE; > -???????event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL); > -???????if (!event.msg_buf) { > -???????????????err = -ENOMEM; > -???????????????goto out; > -???????} > - > -???????while (1) { > -???????????????err = iavf_clean_arq_element(hw, &event, NULL); > -???????????????/* When the AQ is empty, iavf_clean_arq_element will > return > -??????????????? * nonzero and this loop will terminate. > -??????????????? */ > -???????????????if (err) > -???????????????????????goto out_alloc; > -???????????????op = > -?????????????????? (enum > virtchnl_ops)le32_to_cpu(event.desc.cookie_high); > -???????????????if (op == VIRTCHNL_OP_VERSION) > -???????????????????????break; > -???????} > +???????event.msg_buf = kzalloc(IAVF_MAX_AQ_BUF_SIZE, GFP_KERNEL); > +???????if (!event.msg_buf) > +???????????????return -ENOMEM; > ? > +???????err = iavf_poll_virtchnl_msg(&adapter->hw, &event, > VIRTCHNL_OP_VERSION); You're mixing error types. This error is propagated as iavf_status, however, other failuers in this function are returning Linux error codes. The functions following this do this as well. > +???????if (!err) { > +???????????????struct virtchnl_version_info *pf_vvi = > +???????????????????????(struct virtchnl_version_info > *)event.msg_buf; > +???????????????adapter->pf_version = *pf_vvi; > ? > -???????err = (enum iavf_status)le32_to_cpu(event.desc.cookie_low); > -???????if (err) > -???????????????goto out_alloc; > - > -???????if (op != VIRTCHNL_OP_VERSION) { > -???????????????dev_info(&adapter->pdev->dev, "Invalid reply type %d > from PF\n", > -???????????????????????op); > -???????????????err = -EIO; > -???????????????goto out_alloc; > +???????????????if (pf_vvi->major > VIRTCHNL_VERSION_MAJOR || > +?????????????????? (pf_vvi->major == VIRTCHNL_VERSION_MAJOR && > +??????????????????? pf_vvi->minor > VIRTCHNL_VERSION_MINOR)) > +???????????????????????err = -EIO; > ????????} > ? > -???????pf_vvi = (struct virtchnl_version_info *)event.msg_buf; > -???????adapter->pf_version = *pf_vvi; > - > -???????if ((pf_vvi->major > VIRTCHNL_VERSION_MAJOR) || > -?????????? ((pf_vvi->major == VIRTCHNL_VERSION_MAJOR) && > -??????????? (pf_vvi->minor > VIRTCHNL_VERSION_MINOR))) > -???????????????err = -EIO; > - > -out_alloc: > ????????kfree(event.msg_buf); > -out: > + > ????????return err; > ?}