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:   Sun, 6 Aug 2023 13:30:01 +0200
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     Angel Iglesias <ang.iglesiasg@...il.com>
Cc:     linux-iio@...r.kernel.org, Jonathan Cameron <jic23@...nel.org>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] iio: pressure: bmp280: Use i2c_get_match_data

On Sun, Aug 06, 2023 at 01:15:03AM +0200, Angel Iglesias wrote:
> Replaces device_get_match_data() and fallback match_id logic by new
> unified helper function i2c_get_match_data().
> 
> Signed-off-by: Angel Iglesias <ang.iglesiasg@...il.com>
> 
> diff --git a/drivers/iio/pressure/bmp280-i2c.c b/drivers/iio/pressure/bmp280-i2c.c
> index 693eb1975fdc..4ebaa4edc4fc 100644
> --- a/drivers/iio/pressure/bmp280-i2c.c
> +++ b/drivers/iio/pressure/bmp280-i2c.c
> @@ -11,9 +11,9 @@ static int bmp280_i2c_probe(struct i2c_client *client)
>  	const struct bmp280_chip_info *chip_info;
>  	struct regmap *regmap;
>  
> -	chip_info = device_get_match_data(&client->dev);
> +	chip_info = i2c_get_match_data(client);
>  	if (!chip_info)
> -		chip_info = (const struct bmp280_chip_info *) id->driver_data;
> +		return -ENODEV;

the old code assumed that chip_info isn't NULL (implicitly by
dereferencing that pointer in the line below). I wouldn't change
semantics in a patch converting to a helper and so just do:

-	chip_info = device_get_match_data(&client->dev);
+	chip_info = i2c_get_match_data(client);
-	if (!chip_info)
-		chip_info = (const struct bmp280_chip_info *) id->driver_data;

or alternatively, if you think adding a check is a good idea, add an
error message in the error path and mention the semantic change in the
commit log.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ