From: Guenter Roeck <linux@roeck-us.net>
To: Vadim Pasternak <vadimp@mellanox.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v1 hwmon] hwmon: (pmbus) Fix driver info initialization in probe routine
Date: Mon, 18 Feb 2019 07:58:29 -0800 [thread overview]
Message-ID: <20190218155829.GA31609@roeck-us.net> (raw)
In-Reply-To: <20190217174155.25829-1-vadimp@mellanox.com>
Hi,
On Sun, Feb 17, 2019 at 05:41:55PM +0000, Vadim Pasternak wrote:
> Fix tps53679_probe() by using dynamically allocated "pmbus_driver_info"
> structure instead of static. Usage of static structures causes
> overwritten of the field "vrm_version", in case the system is equipped
> with several tps53679 devices with the different "vrm_version".
> In such case the last probed device overwrites this field for all
> others.
>
> Fixes: 610526527a13 ("hwmon: (pmbus) Add support for Texas Instruments tps53679 device")
> Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
> ---
> drivers/hwmon/pmbus/tps53679.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/pmbus/tps53679.c b/drivers/hwmon/pmbus/tps53679.c
> index 85b515cd9df0..45eacc504e2f 100644
> --- a/drivers/hwmon/pmbus/tps53679.c
> +++ b/drivers/hwmon/pmbus/tps53679.c
> @@ -80,7 +80,15 @@ static struct pmbus_driver_info tps53679_info = {
> static int tps53679_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> - return pmbus_do_probe(client, id, &tps53679_info);
> + struct pmbus_driver_info *info;
> +
> + info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL);
> + if (!info)
> + return -ENOMEM;
> +
> + memcpy(info, &tps53679_info, sizeof(*info));
> +
Good find, but why not use devm_kmemdup() ?
Thanks,
Guenter
> + return pmbus_do_probe(client, id, info);
> }
>
> static const struct i2c_device_id tps53679_id[] = {
prev parent reply other threads:[~2019-02-18 15:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-17 17:41 [PATCH v1 hwmon] hwmon: (pmbus) Fix driver info initialization in probe routine Vadim Pasternak
2019-02-18 15:58 ` Guenter Roeck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190218155829.GA31609@roeck-us.net \
--to=linux@roeck-us.net \
--cc=linux-hwmon@vger.kernel.org \
--cc=vadimp@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).