* [PATCH] hwmon: (ads7871) Fix ads7871_probe error path
@ 2010-08-16 1:31 ` Axel Lin
0 siblings, 0 replies; 12+ messages in thread
From: Axel Lin @ 2010-08-16 1:31 UTC (permalink / raw)
To: linux-kernel; +Cc: Paul Thomas, Jean Delvare, lm-sensors
We need to call hwmon_device_unregister() if an error is detected after
sucessfully register hwmon device.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/hwmon/ads7871.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
index b300a20..303db92 100644
--- a/drivers/hwmon/ads7871.c
+++ b/drivers/hwmon/ads7871.c
@@ -201,11 +201,13 @@ static int __devinit ads7871_probe(struct spi_device *spi)
we need to make sure we really have a chip*/
if (val != ret) {
err = -ENODEV;
- goto error_remove;
+ goto error_unregister;
}
return 0;
+error_unregister:
+ hwmon_device_unregister(pdata->hwmon_dev);
error_remove:
sysfs_remove_group(&spi->dev.kobj, &ads7871_group);
error_free:
--
1.7.2
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [lm-sensors] [PATCH] hwmon: (ads7871) Fix ads7871_probe error
2010-08-16 1:31 ` Axel Lin
@ 2010-08-17 11:07 ` Jean Delvare
-1 siblings, 0 replies; 12+ messages in thread
From: Jean Delvare @ 2010-08-17 11:07 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Paul Thomas, lm-sensors
Hi Alex,
On Mon, 16 Aug 2010 09:31:17 +0800, Axel Lin wrote:
> We need to call hwmon_device_unregister() if an error is detected after
> sucessfully register hwmon device.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
> drivers/hwmon/ads7871.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
> index b300a20..303db92 100644
> --- a/drivers/hwmon/ads7871.c
> +++ b/drivers/hwmon/ads7871.c
> @@ -201,11 +201,13 @@ static int __devinit ads7871_probe(struct spi_device *spi)
> we need to make sure we really have a chip*/
> if (val != ret) {
> err = -ENODEV;
> - goto error_remove;
> + goto error_unregister;
> }
>
> return 0;
>
> +error_unregister:
> + hwmon_device_unregister(pdata->hwmon_dev);
> error_remove:
> sysfs_remove_group(&spi->dev.kobj, &ads7871_group);
> error_free:
The bug is real, but I don't think the fix is correct. You should never
have to unregister the hwmon device in the error path, because you
should ensure the hardware is there and working _before_ you register
the hwmon device.
User-space could watch for hwmon devices being added or removed, and
you don't want to trigger such events for a device which isn't going to
work.
So I would suggest reworking the order in which things are done,
leaving hwmon_device_register() at the end of the function. This won't
only fix the error path, this will also close a race window, as for the
moment, the device is exposed to user-space _before_ it it properly
initialized, which is wrong.
Please send an updated patch and I'll be happy to apply it.
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH] hwmon: (ads7871) Fix ads7871_probe error path
@ 2010-08-17 11:07 ` Jean Delvare
0 siblings, 0 replies; 12+ messages in thread
From: Jean Delvare @ 2010-08-17 11:07 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Paul Thomas, lm-sensors
Hi Alex,
On Mon, 16 Aug 2010 09:31:17 +0800, Axel Lin wrote:
> We need to call hwmon_device_unregister() if an error is detected after
> sucessfully register hwmon device.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
> drivers/hwmon/ads7871.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
> index b300a20..303db92 100644
> --- a/drivers/hwmon/ads7871.c
> +++ b/drivers/hwmon/ads7871.c
> @@ -201,11 +201,13 @@ static int __devinit ads7871_probe(struct spi_device *spi)
> we need to make sure we really have a chip*/
> if (val != ret) {
> err = -ENODEV;
> - goto error_remove;
> + goto error_unregister;
> }
>
> return 0;
>
> +error_unregister:
> + hwmon_device_unregister(pdata->hwmon_dev);
> error_remove:
> sysfs_remove_group(&spi->dev.kobj, &ads7871_group);
> error_free:
The bug is real, but I don't think the fix is correct. You should never
have to unregister the hwmon device in the error path, because you
should ensure the hardware is there and working _before_ you register
the hwmon device.
User-space could watch for hwmon devices being added or removed, and
you don't want to trigger such events for a device which isn't going to
work.
So I would suggest reworking the order in which things are done,
leaving hwmon_device_register() at the end of the function. This won't
only fix the error path, this will also close a race window, as for the
moment, the device is exposed to user-space _before_ it it properly
initialized, which is wrong.
Please send an updated patch and I'll be happy to apply it.
--
Jean Delvare
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [lm-sensors] [PATCH] hwmon: (ads7871) Fix ads7871_probe error
2010-08-17 11:07 ` [PATCH] hwmon: (ads7871) Fix ads7871_probe error path Jean Delvare
@ 2010-08-17 15:15 ` Paul Thomas
-1 siblings, 0 replies; 12+ messages in thread
From: Paul Thomas @ 2010-08-17 15:15 UTC (permalink / raw)
To: Jean Delvare; +Cc: Axel Lin, linux-kernel, lm-sensors
On Tue, Aug 17, 2010 at 4:07 AM, Jean Delvare <khali@linux-fr.org> wrote:
> Hi Alex,
>
> On Mon, 16 Aug 2010 09:31:17 +0800, Axel Lin wrote:
>> We need to call hwmon_device_unregister() if an error is detected after
>> sucessfully register hwmon device.
>>
>> Signed-off-by: Axel Lin <axel.lin@gmail.com>
>> ---
>> drivers/hwmon/ads7871.c | 4 +++-
>> 1 files changed, 3 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
>> index b300a20..303db92 100644
>> --- a/drivers/hwmon/ads7871.c
>> +++ b/drivers/hwmon/ads7871.c
>> @@ -201,11 +201,13 @@ static int __devinit ads7871_probe(struct spi_device *spi)
>> we need to make sure we really have a chip*/
>> if (val != ret) {
>> err = -ENODEV;
>> - goto error_remove;
>> + goto error_unregister;
>> }
>>
>> return 0;
>>
>> +error_unregister:
>> + hwmon_device_unregister(pdata->hwmon_dev);
>> error_remove:
>> sysfs_remove_group(&spi->dev.kobj, &ads7871_group);
>> error_free:
>
> The bug is real, but I don't think the fix is correct. You should never
> have to unregister the hwmon device in the error path, because you
> should ensure the hardware is there and working _before_ you register
> the hwmon device.
>
> User-space could watch for hwmon devices being added or removed, and
> you don't want to trigger such events for a device which isn't going to
> work.
>
> So I would suggest reworking the order in which things are done,
> leaving hwmon_device_register() at the end of the function. This won't
> only fix the error path, this will also close a race window, as for the
> moment, the device is exposed to user-space _before_ it it properly
> initialized, which is wrong.
>
> Please send an updated patch and I'll be happy to apply it.
>
> --
> Jean Delvare
>
Should the kzalloc, sysfs_create_group and hwmon_device_register all
stay in the same order just following the register check? I can send a
patch for that.
thanks,
Paul
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH] hwmon: (ads7871) Fix ads7871_probe error path
@ 2010-08-17 15:15 ` Paul Thomas
0 siblings, 0 replies; 12+ messages in thread
From: Paul Thomas @ 2010-08-17 15:15 UTC (permalink / raw)
To: Jean Delvare; +Cc: Axel Lin, linux-kernel, lm-sensors
On Tue, Aug 17, 2010 at 4:07 AM, Jean Delvare <khali@linux-fr.org> wrote:
> Hi Alex,
>
> On Mon, 16 Aug 2010 09:31:17 +0800, Axel Lin wrote:
>> We need to call hwmon_device_unregister() if an error is detected after
>> sucessfully register hwmon device.
>>
>> Signed-off-by: Axel Lin <axel.lin@gmail.com>
>> ---
>> drivers/hwmon/ads7871.c | 4 +++-
>> 1 files changed, 3 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
>> index b300a20..303db92 100644
>> --- a/drivers/hwmon/ads7871.c
>> +++ b/drivers/hwmon/ads7871.c
>> @@ -201,11 +201,13 @@ static int __devinit ads7871_probe(struct spi_device *spi)
>> we need to make sure we really have a chip*/
>> if (val != ret) {
>> err = -ENODEV;
>> - goto error_remove;
>> + goto error_unregister;
>> }
>>
>> return 0;
>>
>> +error_unregister:
>> + hwmon_device_unregister(pdata->hwmon_dev);
>> error_remove:
>> sysfs_remove_group(&spi->dev.kobj, &ads7871_group);
>> error_free:
>
> The bug is real, but I don't think the fix is correct. You should never
> have to unregister the hwmon device in the error path, because you
> should ensure the hardware is there and working _before_ you register
> the hwmon device.
>
> User-space could watch for hwmon devices being added or removed, and
> you don't want to trigger such events for a device which isn't going to
> work.
>
> So I would suggest reworking the order in which things are done,
> leaving hwmon_device_register() at the end of the function. This won't
> only fix the error path, this will also close a race window, as for the
> moment, the device is exposed to user-space _before_ it it properly
> initialized, which is wrong.
>
> Please send an updated patch and I'll be happy to apply it.
>
> --
> Jean Delvare
>
Should the kzalloc, sysfs_create_group and hwmon_device_register all
stay in the same order just following the register check? I can send a
patch for that.
thanks,
Paul
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [lm-sensors] [PATCH] hwmon: (ads7871) Fix ads7871_probe error
2010-08-17 15:15 ` [PATCH] hwmon: (ads7871) Fix ads7871_probe error path Paul Thomas
@ 2010-08-17 18:42 ` Jean Delvare
-1 siblings, 0 replies; 12+ messages in thread
From: Jean Delvare @ 2010-08-17 18:42 UTC (permalink / raw)
To: Paul Thomas; +Cc: Axel Lin, linux-kernel, lm-sensors
On Tue, 17 Aug 2010 08:15:59 -0700, Paul Thomas wrote:
> On Tue, Aug 17, 2010 at 4:07 AM, Jean Delvare <khali@linux-fr.org> wrote:
> > Hi Alex,
> >
> > On Mon, 16 Aug 2010 09:31:17 +0800, Axel Lin wrote:
> >> We need to call hwmon_device_unregister() if an error is detected after
> >> sucessfully register hwmon device.
> >>
> >> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> >> ---
> >> drivers/hwmon/ads7871.c | 4 +++-
> >> 1 files changed, 3 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
> >> index b300a20..303db92 100644
> >> --- a/drivers/hwmon/ads7871.c
> >> +++ b/drivers/hwmon/ads7871.c
> >> @@ -201,11 +201,13 @@ static int __devinit ads7871_probe(struct spi_device *spi)
> >> we need to make sure we really have a chip*/
> >> if (val != ret) {
> >> err = -ENODEV;
> >> - goto error_remove;
> >> + goto error_unregister;
> >> }
> >>
> >> return 0;
> >>
> >> +error_unregister:
> >> + hwmon_device_unregister(pdata->hwmon_dev);
> >> error_remove:
> >> sysfs_remove_group(&spi->dev.kobj, &ads7871_group);
> >> error_free:
> >
> > The bug is real, but I don't think the fix is correct. You should never
> > have to unregister the hwmon device in the error path, because you
> > should ensure the hardware is there and working _before_ you register
> > the hwmon device.
> >
> > User-space could watch for hwmon devices being added or removed, and
> > you don't want to trigger such events for a device which isn't going to
> > work.
> >
> > So I would suggest reworking the order in which things are done,
> > leaving hwmon_device_register() at the end of the function. This won't
> > only fix the error path, this will also close a race window, as for the
> > moment, the device is exposed to user-space _before_ it it properly
> > initialized, which is wrong.
> >
> > Please send an updated patch and I'll be happy to apply it.
> >
> > --
> > Jean Delvare
> >
>
> Should the kzalloc, sysfs_create_group and hwmon_device_register all
> stay in the same order just following the register check? I can send a
> patch for that.
Axel already sent an updated patch, so it's all OK.
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH] hwmon: (ads7871) Fix ads7871_probe error path
@ 2010-08-17 18:42 ` Jean Delvare
0 siblings, 0 replies; 12+ messages in thread
From: Jean Delvare @ 2010-08-17 18:42 UTC (permalink / raw)
To: Paul Thomas; +Cc: Axel Lin, linux-kernel, lm-sensors
On Tue, 17 Aug 2010 08:15:59 -0700, Paul Thomas wrote:
> On Tue, Aug 17, 2010 at 4:07 AM, Jean Delvare <khali@linux-fr.org> wrote:
> > Hi Alex,
> >
> > On Mon, 16 Aug 2010 09:31:17 +0800, Axel Lin wrote:
> >> We need to call hwmon_device_unregister() if an error is detected after
> >> sucessfully register hwmon device.
> >>
> >> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> >> ---
> >> drivers/hwmon/ads7871.c | 4 +++-
> >> 1 files changed, 3 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
> >> index b300a20..303db92 100644
> >> --- a/drivers/hwmon/ads7871.c
> >> +++ b/drivers/hwmon/ads7871.c
> >> @@ -201,11 +201,13 @@ static int __devinit ads7871_probe(struct spi_device *spi)
> >> we need to make sure we really have a chip*/
> >> if (val != ret) {
> >> err = -ENODEV;
> >> - goto error_remove;
> >> + goto error_unregister;
> >> }
> >>
> >> return 0;
> >>
> >> +error_unregister:
> >> + hwmon_device_unregister(pdata->hwmon_dev);
> >> error_remove:
> >> sysfs_remove_group(&spi->dev.kobj, &ads7871_group);
> >> error_free:
> >
> > The bug is real, but I don't think the fix is correct. You should never
> > have to unregister the hwmon device in the error path, because you
> > should ensure the hardware is there and working _before_ you register
> > the hwmon device.
> >
> > User-space could watch for hwmon devices being added or removed, and
> > you don't want to trigger such events for a device which isn't going to
> > work.
> >
> > So I would suggest reworking the order in which things are done,
> > leaving hwmon_device_register() at the end of the function. This won't
> > only fix the error path, this will also close a race window, as for the
> > moment, the device is exposed to user-space _before_ it it properly
> > initialized, which is wrong.
> >
> > Please send an updated patch and I'll be happy to apply it.
> >
> > --
> > Jean Delvare
> >
>
> Should the kzalloc, sysfs_create_group and hwmon_device_register all
> stay in the same order just following the register check? I can send a
> patch for that.
Axel already sent an updated patch, so it's all OK.
--
Jean Delvare
^ permalink raw reply [flat|nested] 12+ messages in thread
* [lm-sensors] [PATCH] hwmon: (ads7871) Fix ads7871_probe init path
@ 2010-08-22 14:25 ` Axel Lin
0 siblings, 0 replies; 12+ messages in thread
From: Axel Lin @ 2010-08-22 14:25 UTC (permalink / raw)
To: linux-kernel; +Cc: Paul Thomas, Jean Delvare, lm-sensors
From 81e895683eaecb9e196c57c36b774c0908069d83 Mon Sep 17 00:00:00 2001
From: Axel Lin <axel.lin@gmail.com>
Date: Sun, 22 Aug 2010 22:10:01 +0800
Subject: [PATCH] hwmon: (ads7871) Fix ads7871_probe init path
This patch includes below fixes:
1. remove 'status' variable
2. remove unneeded initialization of 'err' variable
3. return missing error code if sysfs_create_group fail.
4. fix the init sequence as:
- check hardware existence
- kzalloc for ads7871_data
- sysfs_create_group
- hwmon_device_register
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
hi Jean,
This patch is against linux-next ( on top of previous patch ).
Reviews are welcome.
I think it's ok to call sysfs_create_group() before hwmon_device_register().
If hwmon_device_register failed, the device is not working anyway.
We just need to make sure all the allocated resources are reclaimed in error path before return error.
Regards,
Axel
drivers/hwmon/ads7871.c | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
index 45f5829..5231934 100644
--- a/drivers/hwmon/ads7871.c
+++ b/drivers/hwmon/ads7871.c
@@ -160,24 +160,12 @@ static const struct attribute_group ads7871_group = {
static int __devinit ads7871_probe(struct spi_device *spi)
{
- int status, ret, err = 0;
+ int ret, err;
uint8_t val;
struct ads7871_data *pdata;
dev_dbg(&spi->dev, "probe\n");
- pdata = kzalloc(sizeof(struct ads7871_data), GFP_KERNEL);
- if (!pdata) {
- err = -ENOMEM;
- goto exit;
- }
-
- status = sysfs_create_group(&spi->dev.kobj, &ads7871_group);
- if (status < 0)
- goto error_free;
-
- spi_set_drvdata(spi, pdata);
-
/* Configure the SPI bus */
spi->mode = (SPI_MODE_0);
spi->bits_per_word = 8;
@@ -195,9 +183,21 @@ static int __devinit ads7871_probe(struct spi_device *spi)
we need to make sure we really have a chip*/
if (val != ret) {
err = -ENODEV;
- goto error_remove;
+ goto exit;
}
+ pdata = kzalloc(sizeof(struct ads7871_data), GFP_KERNEL);
+ if (!pdata) {
+ err = -ENOMEM;
+ goto exit;
+ }
+
+ err = sysfs_create_group(&spi->dev.kobj, &ads7871_group);
+ if (err < 0)
+ goto error_free;
+
+ spi_set_drvdata(spi, pdata);
+
pdata->hwmon_dev = hwmon_device_register(&spi->dev);
if (IS_ERR(pdata->hwmon_dev)) {
err = PTR_ERR(pdata->hwmon_dev);
--
1.7.0.4
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH] hwmon: (ads7871) Fix ads7871_probe init path
@ 2010-08-22 14:25 ` Axel Lin
0 siblings, 0 replies; 12+ messages in thread
From: Axel Lin @ 2010-08-22 14:25 UTC (permalink / raw)
To: linux-kernel; +Cc: Paul Thomas, Jean Delvare, lm-sensors
>From 81e895683eaecb9e196c57c36b774c0908069d83 Mon Sep 17 00:00:00 2001
From: Axel Lin <axel.lin@gmail.com>
Date: Sun, 22 Aug 2010 22:10:01 +0800
Subject: [PATCH] hwmon: (ads7871) Fix ads7871_probe init path
This patch includes below fixes:
1. remove 'status' variable
2. remove unneeded initialization of 'err' variable
3. return missing error code if sysfs_create_group fail.
4. fix the init sequence as:
- check hardware existence
- kzalloc for ads7871_data
- sysfs_create_group
- hwmon_device_register
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
hi Jean,
This patch is against linux-next ( on top of previous patch ).
Reviews are welcome.
I think it's ok to call sysfs_create_group() before hwmon_device_register().
If hwmon_device_register failed, the device is not working anyway.
We just need to make sure all the allocated resources are reclaimed in error path before return error.
Regards,
Axel
drivers/hwmon/ads7871.c | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
index 45f5829..5231934 100644
--- a/drivers/hwmon/ads7871.c
+++ b/drivers/hwmon/ads7871.c
@@ -160,24 +160,12 @@ static const struct attribute_group ads7871_group = {
static int __devinit ads7871_probe(struct spi_device *spi)
{
- int status, ret, err = 0;
+ int ret, err;
uint8_t val;
struct ads7871_data *pdata;
dev_dbg(&spi->dev, "probe\n");
- pdata = kzalloc(sizeof(struct ads7871_data), GFP_KERNEL);
- if (!pdata) {
- err = -ENOMEM;
- goto exit;
- }
-
- status = sysfs_create_group(&spi->dev.kobj, &ads7871_group);
- if (status < 0)
- goto error_free;
-
- spi_set_drvdata(spi, pdata);
-
/* Configure the SPI bus */
spi->mode = (SPI_MODE_0);
spi->bits_per_word = 8;
@@ -195,9 +183,21 @@ static int __devinit ads7871_probe(struct spi_device *spi)
we need to make sure we really have a chip*/
if (val != ret) {
err = -ENODEV;
- goto error_remove;
+ goto exit;
}
+ pdata = kzalloc(sizeof(struct ads7871_data), GFP_KERNEL);
+ if (!pdata) {
+ err = -ENOMEM;
+ goto exit;
+ }
+
+ err = sysfs_create_group(&spi->dev.kobj, &ads7871_group);
+ if (err < 0)
+ goto error_free;
+
+ spi_set_drvdata(spi, pdata);
+
pdata->hwmon_dev = hwmon_device_register(&spi->dev);
if (IS_ERR(pdata->hwmon_dev)) {
err = PTR_ERR(pdata->hwmon_dev);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [lm-sensors] [PATCH] hwmon: (ads7871) Fix ads7871_probe init
2010-08-22 14:25 ` Axel Lin
@ 2010-08-22 20:48 ` Jean Delvare
-1 siblings, 0 replies; 12+ messages in thread
From: Jean Delvare @ 2010-08-22 20:48 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Paul Thomas, lm-sensors
Hi Axel,
On Sun, 22 Aug 2010 22:25:26 +0800, Axel Lin wrote:
> >From 81e895683eaecb9e196c57c36b774c0908069d83 Mon Sep 17 00:00:00 2001
> From: Axel Lin <axel.lin@gmail.com>
> Date: Sun, 22 Aug 2010 22:10:01 +0800
> Subject: [PATCH] hwmon: (ads7871) Fix ads7871_probe init path
>
> This patch includes below fixes:
>
> 1. remove 'status' variable
> 2. remove unneeded initialization of 'err' variable
> 3. return missing error code if sysfs_create_group fail.
> 4. fix the init sequence as:
> - check hardware existence
> - kzalloc for ads7871_data
> - sysfs_create_group
> - hwmon_device_register
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
>
> hi Jean,
> This patch is against linux-next ( on top of previous patch ).
> Reviews are welcome.
Looks good. I've folded this patch into the old one, and will send the
result to Linux shortly.
> I think it's ok to call sysfs_create_group() before hwmon_device_register().
> If hwmon_device_register failed, the device is not working anyway.
> We just need to make sure all the allocated resources are reclaimed in error path before return error.
Agreed.
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] hwmon: (ads7871) Fix ads7871_probe init path
@ 2010-08-22 20:48 ` Jean Delvare
0 siblings, 0 replies; 12+ messages in thread
From: Jean Delvare @ 2010-08-22 20:48 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Paul Thomas, lm-sensors
Hi Axel,
On Sun, 22 Aug 2010 22:25:26 +0800, Axel Lin wrote:
> >From 81e895683eaecb9e196c57c36b774c0908069d83 Mon Sep 17 00:00:00 2001
> From: Axel Lin <axel.lin@gmail.com>
> Date: Sun, 22 Aug 2010 22:10:01 +0800
> Subject: [PATCH] hwmon: (ads7871) Fix ads7871_probe init path
>
> This patch includes below fixes:
>
> 1. remove 'status' variable
> 2. remove unneeded initialization of 'err' variable
> 3. return missing error code if sysfs_create_group fail.
> 4. fix the init sequence as:
> - check hardware existence
> - kzalloc for ads7871_data
> - sysfs_create_group
> - hwmon_device_register
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
>
> hi Jean,
> This patch is against linux-next ( on top of previous patch ).
> Reviews are welcome.
Looks good. I've folded this patch into the old one, and will send the
result to Linux shortly.
> I think it's ok to call sysfs_create_group() before hwmon_device_register().
> If hwmon_device_register failed, the device is not working anyway.
> We just need to make sure all the allocated resources are reclaimed in error path before return error.
Agreed.
--
Jean Delvare
^ permalink raw reply [flat|nested] 12+ messages in thread