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: <2024070447-cosigner-shanty-fbbd@gregkh>
Date: Thu, 4 Jul 2024 13:50:43 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Akshay Gupta <akshay.gupta@....com>
Cc: linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux@...ck-us.net, arnd@...db.de, naveenkrishna.chatradhi@....com
Subject: Re: [PATCH 2/6] misc: sbrmi: Add platform device add to create
 platform device

On Thu, Jul 04, 2024 at 11:16:20AM +0000, Akshay Gupta wrote:
> - AMD provides socket power information from out of band
>   which can be read by sensors.
> - platform driver will probe drivers/hwmon/sbrmi as a platform device
>   and share the sbrmi device data.

So you are "splitting" a real device into different ones using a
platform device?  THat's not ok, and an abuse of the platform api.
Please use the correct one for that instead.


> 
> Signed-off-by: Akshay Gupta <akshay.gupta@....com>
> Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@....com>
> ---
>  drivers/misc/amd-sb/sbrmi-i2c.c | 25 ++++++++++++++++++++++++-
>  include/misc/amd-sb.h           |  2 ++
>  2 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/amd-sb/sbrmi-i2c.c b/drivers/misc/amd-sb/sbrmi-i2c.c
> index c4903d9e9f0f..b593bbdd78e0 100644
> --- a/drivers/misc/amd-sb/sbrmi-i2c.c
> +++ b/drivers/misc/amd-sb/sbrmi-i2c.c
> @@ -72,7 +72,29 @@ static int sbrmi_i2c_probe(struct i2c_client *client)
>  		return ret;
>  
>  	/* Cache maximum power limit */
> -	return sbrmi_get_max_pwr_limit(data);
> +	ret = sbrmi_get_max_pwr_limit(data);
> +	if (ret < 0)
> +		return ret;
> +
> +	dev_set_drvdata(dev, (void *)data);

No need to cast, right?

> +	data->pdev = platform_device_register_data(dev, "sbrmi-hwmon",
> +						   PLATFORM_DEVID_NONE,

Yeah, that's not ok.  Please do this correctly, as this is NOT a
platform device, but rather a made-up one that you just created out of
no where.  Instead use the correct apis for that.

> +						   data,
> +						   sizeof(struct sbrmi_data));
> +	if (IS_ERR(data->pdev)) {
> +		pr_err("unable to register platform device for sbrmi-hwmon\n");
> +		return PTR_ERR(data->pdev);

You don't need to unwind anything else here?



> +	}
> +	return ret;
> +}
> +
> +static void sbrmi_i2c_remove(struct i2c_client *client)
> +{
> +	struct sbrmi_data *data = dev_get_drvdata(&client->dev);
> +
> +	if (!data)
> +		return;

How can that happen?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ