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: <e519e9f2-5e25-4ec3-afb4-42d15da941aa@gmail.com>
Date: Sun, 30 Jun 2024 00:00:26 +0200
From: Heiner Kallweit <hkallweit1@...il.com>
To: Guenter Roeck <linux@...ck-us.net>, linux-kernel@...r.kernel.org
Cc: Arnd Bergmann <arnd@...db.de>,
 Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
 Thomas Weißschuh <linux@...ssschuh.net>
Subject: Re: [PATCH 1/2] eeprom: ee1004: Call i2c_new_scanned_device to
 instantiate thermal sensor

On 29.06.2024 19:37, Guenter Roeck wrote:
> Instantiating a device by calling i2c_new_client_device() assumes that the
> device is not already instantiated. If that is not the case, it will return
> an error and generate a misleading kernel log message.
> 
> i2c i2c-0: Failed to register i2c client jc42 at 0x18 (-16)
> 
> This can be reproduced by unloading the ee1004 driver and loading it again.
> 
> Avoid this by calling i2c_new_scanned_device() instead, which returns
> silently if a device is already instantiated or does not exist.
> 
However i2c_new_scanned_device() runs i2c_default_probe() on the device,
whilst i2c_new_client_device() doesn't access the i2c bus.
If possible I'd like to avoid this overhead.

> Fixes: 393bd1000f81 ("eeprom: ee1004: add support for temperature sensor")
> Cc: Heiner Kallweit <hkallweit1@...il.com>
> Cc: Thomas Weißschuh <linux@...ssschuh.net>
> Signed-off-by: Guenter Roeck <linux@...ck-us.net>
> ---
>  drivers/misc/eeprom/ee1004.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/misc/eeprom/ee1004.c b/drivers/misc/eeprom/ee1004.c
> index 21feebc3044c..71ca66d1df82 100644
> --- a/drivers/misc/eeprom/ee1004.c
> +++ b/drivers/misc/eeprom/ee1004.c
> @@ -185,6 +185,8 @@ BIN_ATTRIBUTE_GROUPS(ee1004);
>  static void ee1004_probe_temp_sensor(struct i2c_client *client)
>  {
>  	struct i2c_board_info info = { .type = "jc42" };
> +	unsigned short addr = 0x18 | (client->addr & 7);
> +	unsigned short addr_list[] = { addr, I2C_CLIENT_END };
>  	u8 byte14;
>  	int ret;
>  
> @@ -193,9 +195,7 @@ static void ee1004_probe_temp_sensor(struct i2c_client *client)
>  	if (ret != 1 || !(byte14 & BIT(7)))
>  		return;
>  
> -	info.addr = 0x18 | (client->addr & 7);
> -
> -	i2c_new_client_device(client->adapter, &info);
> +	i2c_new_scanned_device(client->adapter, &info, addr_list, NULL);
>  }
>  
>  static void ee1004_cleanup(int idx, struct ee1004_bus_data *bd)


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ