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]
Date:	Sun, 14 Apr 2013 12:55:14 +0200
From:	Francois Romieu <romieu@...zoreil.com>
To:	Shahed Shaikh <shahed.shaikh@...gic.com>
Cc:	davem@...emloft.net, netdev@...r.kernel.org,
	Dept_NX_Linux_NIC_Driver@...gic.com,
	Himanshu Madhani <himanshu.madhani@...gic.com>
Subject: Re: [PATCH net-next 1/9] qlcnic: Implement GET_LED_STATUS command
 for 82xx adapter.

Shahed Shaikh <shahed.shaikh@...gic.com> :
[...]
> diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c
> index 253b3ac..3784bef 100644
> --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c
> +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c
> @@ -1462,6 +1462,29 @@ int qlcnic_82xx_config_led(struct qlcnic_adapter *adapter, u32 state, u32 rate)
>  	return rv;
>  }
>  
> +int qlcnic_get_beacon_state(struct qlcnic_adapter *adapter, u8 *h_state)
> +{
> +	int err = 0;
> +	struct qlcnic_cmd_args cmd;

The scope of this variable could have been narrowed.

> +
> +	if (adapter->ahw->capabilities2 & QLCNIC_FW_CAPABILITY_2_BEACON) {
> +		err = qlcnic_alloc_mbx_args(&cmd, adapter,
> +					    QLCNIC_CMD_GET_LED_STATUS);
> +		if (err)
> +			goto error;
> +
> +		err = qlcnic_issue_cmd(adapter, &cmd);
> +		if (err)
> +			err = -EIO;

qlcnic_issue_cmd should return a proper error code so that there is no
reason to smash it.

> +		else
> +			*h_state = cmd.rsp.arg[1];
> +
> +		qlcnic_free_mbx_args(&cmd);
> +	}
> +error:
> +	return err;
> +}

Normal path going through an "error" label... :o/

Please compare with:

int qlcnic_get_beacon_state(struct qlcnic_adapter *adapter, u8 *h_state)
{
	struct qlcnic_cmd_args cmd;
	int rc;

	if (!(adapter->ahw->capabilities2 & QLCNIC_FW_CAPABILITY_2_BEACON))
		return 0;

	rc = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_GET_LED_STATUS);
	if (!rc) {
		rc = qlcnic_issue_cmd(adapter, &cmd);
		if (!rc)
			*h_state = cmd.rsp.arg[1];

		qlcnic_free_mbx_args(&cmd);
	}

	return rc;
}
	
[...]
> diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
> index c77675d..a17671d 100644
> --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
> +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
[...]
> @@ -174,6 +175,14 @@ beacon_err:
>  	if (err)
>  		return err;
>  
> +	err = qlcnic_get_beacon_state(adapter, &h_beacon_state);
> +	if (err != -EIO) {
> +		if (h_beacon_state == QLCNIC_BEACON_DISABLE)
> +			adapter->ahw->beacon_state = 0;
> +		else
> +			adapter->ahw->beacon_state = 2;

Nit: what about a ternary ?

		adapter->ahw->beacon_state =
			(h_beacon_state == QLCNIC_BEACON_DISABLE) ? 0 : 2;

You should consider reworking qlcnic_store_beacon. It's in a sad state
(multiple return points and locks as well as a big inline reset path).

-- 
Ueimor
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ