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-next>] [day] [month] [year] [list]
Message-ID: <20200807173231.GA47449@roeck-us.net>
Date:   Fri, 7 Aug 2020 10:32:31 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Stephen Kitt <steve@....org>
Cc:     Jean Delvare <jdelvare@...e.com>, linux-hwmon@...r.kernel.org,
        linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org,
        Wolfram Sang <wsa@...nel.org>
Subject: Re: [PATCH v3] hwmon/pmbus: use simple i2c probe function

On Fri, Aug 07, 2020 at 06:28:01PM +0200, Stephen Kitt wrote:
> pmbus_do_probe doesn't use the id information provided in its second
> argument, so this can be removed, which then allows using the
> single-parameter i2c probe function ("probe_new") for probes.
> 
> This avoids scanning the identifier tables during probes.
> 
> Drivers which didn't use the id are converted as-is; drivers which did
> are modified as follows:
> 
> * if the information in i2c_client is sufficient, that's used instead
>   (client->name);
> * configured v. probed comparisons are performed by comparing the
>   configured name to the detected name, instead of the ids; this
>   involves strcmp but is still cheaper than comparing all the device
>   names when scanning the tables;
> * anything else is handled by calling i2c_match_id() with the same
>   level of error-handling (if any) as before.
> 
> Signed-off-by: Stephen Kitt <steve@....org>
> ---
> Changes since v1:
>   - i2c_device_id declarations are left unchanged;
>   - all drivers are converted, using client info or i2c_match_id().
> Changes since v2:
>   - updated the documentation;
>   - fixed unbalanced braces around the modified else in ibm-cffps.c.
> 

[ ... ]

>  
> -static int ltc2978_probe(struct i2c_client *client,
> -			 const struct i2c_device_id *id)
> +static int ltc2978_probe(struct i2c_client *client)
>  {
>  	int i, chip_id;
>  	struct ltc2978_data *data;
> @@ -670,10 +669,10 @@ static int ltc2978_probe(struct i2c_client *client,
>  		return chip_id;
>  
>  	data->id = chip_id;
> -	if (data->id != id->driver_data)
> +	if (strcmp(client->name, ltc2978_id[data->id].name) != 0)

I was about to apply this patch, but this is problematic: It assumes that
__stringify(id) == ltc2978_id[id].name and that ltc2978_id[id].driver_data
== id. While that is curently the case (as far as I can see), it is still
unsafe. I think it would be much safer to use i2c_match_id() here.

Thanks,
Guenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ