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:   Mon, 7 Jun 2021 11:31:14 +0200
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     Jiri Prchal <jiri.prchal@...ignal.cz>
Cc:     devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
        Rob Herring <robh+dt@...nel.org>,
        Christian Eggers <ceggers@...i.de>,
        Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH v6 4/5] nvmem: eeprom: at25: export FRAM serial num

On Mon, Jun 07, 2021 at 10:26:37AM +0200, Jiri Prchal wrote:
> This exports serial number of FRAM in sysfs file named "sernum".
> Formatted in hex, each byte separated by space.
> Example:
> $ cat /sys/class/spi_master/spi0/spi0.0/sernum
> 0000a43644f2ae6c
> 
> Signed-off-by: Jiri Prchal <jiri.prchal@...ignal.cz>
> ---
> v2: no change here
> v3: resend and added more recipients
> v4: resend
> v5: reworked up on Greg comments: no spaces in string, sysfs done correctly
> v6: no change here
> ---
>  drivers/misc/eeprom/at25.c | 28 +++++++++++++++++++++++++++-
>  1 file changed, 27 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c
> index 45a486994828..4e4fa8d3ba5d 100644
> --- a/drivers/misc/eeprom/at25.c
> +++ b/drivers/misc/eeprom/at25.c
> @@ -39,6 +39,7 @@ struct at25_data {
>  	struct nvmem_config	nvmem_config;
>  	struct nvmem_device	*nvmem;
>  	int has_sernum;
> +	char *sernum;
>  };
>  
>  #define	AT25_WREN	0x06		/* latch the write enable */
> @@ -173,6 +174,25 @@ static int fm25_aux_read(struct at25_data *at25, char *buf, uint8_t command,
>  	return status;
>  }
>  
> +static ssize_t sernum_show(struct device *dev, struct device_attribute *attr, char *buf)
> +{
> +	struct at25_data *at25;
> +	int i;
> +
> +	at25 = dev_get_drvdata(dev);
> +	for (i = FM25_SN_LEN - 1; i >= 0; i--)
> +		buf += sprintf(buf, "%02x", at25->sernum[i]);
> +	sprintf(buf, "\n");

Please use sysfs_emit() with the proper print modifier for an array of
bytes in hex (I think there is one...)

> +	return (2 * FM25_SN_LEN + 1);
> +}
> +static DEVICE_ATTR(sernum, 0440, sernum_show, NULL);

DEVICE_ATTR_RO() please.


> +
> +static struct attribute *sernum_attrs[] = {
> +	&dev_attr_sernum.attr,
> +	NULL,
> +};
> +ATTRIBUTE_GROUPS(sernum);
> +
>  static int at25_ee_write(void *priv, unsigned int off, void *val, size_t count)
>  {
>  	struct at25_data *at25 = priv;
> @@ -417,8 +437,13 @@ static int at25_probe(struct spi_device *spi)
>  		else
>  			at25->chip.flags |= EE_ADDR2;
>  
> -		if (id[8])
> +		if (id[8]) {
>  			at25->has_sernum = 1;
> +			at25->sernum = kzalloc(FM25_SN_LEN, GFP_KERNEL);

Where do you free this memory?

And why does it have to be 0 filled?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ