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 for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <BN8PR11MB36689A85AE21AA78FDA79991E9B29@BN8PR11MB3668.namprd11.prod.outlook.com>
Date:   Thu, 2 Mar 2023 06:18:33 +0000
From:   <Kumaravel.Thiagarajan@...rochip.com>
To:     <VaibhaavRam.TL@...rochip.com>, <arnd@...db.de>
CC:     <gregkh@...uxfoundation.org>, <linux-kernel@...r.kernel.org>,
        <UNGLinuxDriver@...rochip.com>,
        <Tharunkumar.Pasumarthi@...rochip.com>
Subject: RE: [PATCH v6 char-misc-next] misc: microchip: pci1xxxx: Add
 OTP/EEPROM driver for the pci1xxxx switch

> -----Original Message-----
> From: Vaibhaav Ram T.L <vaibhaavram.tl@...rochip.com>
> Sent: Tuesday, February 28, 2023 11:34 PM
> Microchip's pci1xxxx is an unmanaged PCIe3.1a switch for consumer,
> industrial, and automotive applications. This switch integrates OTP and
> EEPROM to enable customization of the part in the field. This patch provides
> the OTP/EEPROM driver to support the same.
> 
> +static int otp_eeprom_create_device(struct auxiliary_device *aux_dev) {
> +	struct auxiliary_device_wrapper *aux_dev_wrapper;
> +	struct pci1xxxx_otp_eeprom_device *priv;
> +	struct gp_aux_data_type *pdata;
> +	int ret;
> +
> +	aux_dev_wrapper = container_of(aux_dev, struct
> auxiliary_device_wrapper,
> +				       aux_dev);
> +	pdata = &aux_dev_wrapper->gp_aux_data;
> +	if (!pdata)
> +		return dev_err_probe(&aux_dev->dev, -EINVAL,
> +				     "Invalid data in aux_dev_wrapper-
> >gp_aux_data\n");
> +
> +	priv = devm_kzalloc(&aux_dev->dev, sizeof(*priv), GFP_KERNEL);
> +	if (!priv)
> +		return dev_err_probe(&aux_dev->dev, -ENOMEM,
> +				     "Memory Allocation Failed\n");
> +
> +	priv->pdev = aux_dev;
> +	dev_set_drvdata(&aux_dev->dev, priv);
> +
> +	if (!devm_request_mem_region(&aux_dev->dev, pdata-
> >region_start +
> +				     PERI_PF3_SYSTEM_REG_ADDR_BASE,
> +				     PERI_PF3_SYSTEM_REG_LENGTH,
> +				     aux_dev->name))
> +		return dev_err_probe(&aux_dev->dev, -ENOMEM,
> +				     "can't request otpeeprom region\n");
> +
> +	priv->reg_base = devm_ioremap(&aux_dev->dev, pdata-
> >region_start +
> +				      PERI_PF3_SYSTEM_REG_ADDR_BASE,
> +				      PERI_PF3_SYSTEM_REG_LENGTH);
> +	if (!priv->reg_base)
> +		return dev_err_probe(&aux_dev->dev, -ENOMEM,
> "ioremap failed\n");
> +
> +	ret = sysfs_create_bin_file(&aux_dev->dev.kobj,
> &pci1xxxx_eeprom_attr);
Check whether EEPROM is present and accessible as expected before enumerating.
Enumerate OTP first as it is always present before checking for EEPROM.
> +	if (ret)
> +		return dev_err_probe(&aux_dev->dev, ret,
> +				     "sysfs_create_bin_file eeprom failed\n");
> +
> +	ret = sysfs_create_bin_file(&aux_dev->dev.kobj,
> &pci1xxxx_otp_attr);
> +	if (ret)
> +		return dev_err_probe(&aux_dev->dev, ret,
> +				     "sysfs_create_bin_file otp failed\n");
Test the error handling - if the function fails here what happens to the previously created
Sysfs file.
> +
> +	return ret;
> +}

Thank You.

Regards,
Kumar

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ