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: <01c09e14-e991-4c3f-a747-3cfd591c56e8@oracle.com>
Date: Thu, 7 Mar 2024 10:04:41 +0000
From: John Garry <john.g.garry@...cle.com>
To: Xingui Yang <yangxingui@...wei.com>, yanaijie@...wei.com,
        jejb@...ux.ibm.com, martin.petersen@...cle.com,
        damien.lemoal@...nsource.wdc.com
Cc: linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
        linuxarm@...wei.com, prime.zeng@...ilicon.com,
        chenxiang66@...ilicon.com, kangfenglong@...wei.com
Subject: Re: [PATCH v3 2/3] scsi: libsas: Add a helper
 sas_get_sas_addr_and_dev_type()

On 07/03/2024 09:37, Xingui Yang wrote:
> Add a helper to get attached_sas_addr and device type from disc_resp.
> 
> Suggested-by: John Garry <john.g.garry@...cle.com>
> Signed-off-by: Xingui Yang <yangxingui@...wei.com>

Reviewed-by: John Garry <john.g.garry@...cle.com>

> ---
>   drivers/scsi/libsas/sas_expander.c | 19 ++++++++++++-------
>   1 file changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
> index 1eeb69cba8da..d6147616339f 100644
> --- a/drivers/scsi/libsas/sas_expander.c
> +++ b/drivers/scsi/libsas/sas_expander.c
> @@ -1631,6 +1631,16 @@ int sas_discover_root_expander(struct domain_device *dev)
>   
>   /* ---------- Domain revalidation ---------- */
>   
> +static void sas_get_sas_addr_and_dev_type(struct smp_disc_resp *disc_resp,
> +					  u8 *sas_addr,
> +					  enum sas_device_type *type)
> +{
> +	memcpy(sas_addr, disc_resp->disc.attached_sas_addr, SAS_ADDR_SIZE);
> +	*type = to_dev_type(&disc_resp->disc);
> +	if (*type == SAS_PHY_UNUSED)
> +		memset(sas_addr, 0, SAS_ADDR_SIZE);
> +}
> +
>   static int sas_get_phy_discover(struct domain_device *dev,
>   				int phy_id, struct smp_disc_resp *disc_resp)
>   {
> @@ -1684,13 +1694,8 @@ int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id,
>   		return -ENOMEM;
>   
>   	res = sas_get_phy_discover(dev, phy_id, disc_resp);

At some stage - I am not saying necessarily now! - it would be good to 
stop this function returning both a linux error code and a SAS protocol 
response code

> -	if (res == 0) {
> -		memcpy(sas_addr, disc_resp->disc.attached_sas_addr,
> -		       SAS_ADDR_SIZE);
> -		*type = to_dev_type(&disc_resp->disc);
> -		if (*type == 0)
> -			memset(sas_addr, 0, SAS_ADDR_SIZE);
> -	}
> +	if (res == 0)
> +		sas_get_sas_addr_and_dev_type(disc_resp, sas_addr, type);
>   	kfree(disc_resp);
>   	return res;
>   }


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ