lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <A1F3F9E0764A4308+20250822065132.GA1942990@nic-Precision-5820-Tower>
Date: Fri, 22 Aug 2025 14:51:32 +0800
From: Yibo Dong <dong100@...se.com>
To: Parthiban.Veerasooran@...rochip.com
Cc: andrew+netdev@...n.ch, davem@...emloft.net, edumazet@...gle.com,
	kuba@...nel.org, pabeni@...hat.com, horms@...nel.org,
	corbet@....net, gur.stavi@...wei.com, maddy@...ux.ibm.com,
	mpe@...erman.id.au, danishanwar@...com, lee@...ger.us,
	gongfan1@...wei.com, lorenzo@...nel.org, geert+renesas@...der.be,
	lukas.bulwahn@...hat.com, alexanderduyck@...com,
	richardcochran@...il.com, kees@...nel.org, gustavoars@...nel.org,
	netdev@...r.kernel.org, linux-doc@...r.kernel.org,
	linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH net-next v7 4/5] net: rnpgbe: Add basic mbx_fw support

On Fri, Aug 22, 2025 at 06:07:51AM +0000, Parthiban.Veerasooran@...rochip.com wrote:
> On 22/08/25 11:07 am, Yibo Dong wrote:
> > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> > 
> > On Fri, Aug 22, 2025 at 04:49:44AM +0000, Parthiban.Veerasooran@...rochip.com wrote:
> >> On 22/08/25 8:04 am, Dong Yibo wrote:
> >>> +/**
> >>> + * mucse_mbx_get_capability - Get hw abilities from fw
> >>> + * @hw: pointer to the HW structure
> >>> + *
> >>> + * mucse_mbx_get_capability tries to get capabities from
> >>> + * hw. Many retrys will do if it is failed.
> >>> + *
> >>> + * @return: 0 on success, negative on failure
> >>> + **/
> >>> +int mucse_mbx_get_capability(struct mucse_hw *hw)
> >>> +{
> >>> +       struct hw_abilities ability = {};
> >>> +       int try_cnt = 3;
> >>> +       int err = -EIO;
> >> Here too you no need to assign -EIO as it is updated in the while.
> >>
> >> Best regards,
> >> Parthiban V
> >>> +
> >>> +       while (try_cnt--) {
> >>> +               err = mucse_fw_get_capability(hw, &ability);
> >>> +               if (err)
> >>> +                       continue;
> >>> +               hw->pfvfnum = le16_to_cpu(ability.pfnum) & GENMASK_U16(7, 0);
> >>> +               return 0;
> >>> +       }
> >>> +       return err;
> >>> +}
> >>> +
> > 
> > err is updated because 'try_cnt = 3'. But to the code logic itself, it should
> > not leave err uninitialized since no guarantee that codes 'whthin while'
> > run at least once. Right?
> Yes, but 'try_cnt' is hard coded as 3, so the 'while loop' will always 
> execute and err will definitely be updated.
> 
> So in this case, the check isn’t needed unless try_cnt is being modified 
> externally with unknown values, which doesn’t seem to be happening here.
> 
> Best regards,
> Parthiban V
> > 
> > Thanks for your feedback.
> > 
> > 
> 

Is it fine if I add some comment like this?
.....
/* Initialized as a defensive measure to handle edge cases
 * where try_cnt might be modified
 */
 int err = -EIO;
.....

Additionally, keeping this initialization ensures we’ll no need to consider
its impact every time 'try_cnt' is modified (Although this situation is
almost impossible). 

Thanks for your feedback.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ