public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Garzik <jeff@garzik.org>
To: j.w.r.degoede@hhs.nl, khali@linux-fr.org,
	Andrew Morton <akpm@osdl.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] hwmon/abituguru: handle sysfs errors
Date: Tue, 10 Oct 2006 02:53:59 -0400	[thread overview]
Message-ID: <20061010065359.GA21576@havoc.gtf.org> (raw)


Signed-off-by: Jeff Garzik <jeff@garzik.org>

---

 drivers/hwmon/abituguru.c |   30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

2b10f648c8ed965369976eb7925b922ee187ce21
diff --git a/drivers/hwmon/abituguru.c b/drivers/hwmon/abituguru.c
index e5cb0fd..3ded982 100644
--- a/drivers/hwmon/abituguru.c
+++ b/drivers/hwmon/abituguru.c
@@ -1271,14 +1271,34 @@ static int __devinit abituguru_probe(str
 		res = PTR_ERR(data->class_dev);
 		goto abituguru_probe_error;
 	}
-	for (i = 0; i < sysfs_attr_i; i++)
-		device_create_file(&pdev->dev, &data->sysfs_attr[i].dev_attr);
-	for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++)
-		device_create_file(&pdev->dev,
-			&abituguru_sysfs_attr[i].dev_attr);
+	for (i = 0; i < sysfs_attr_i; i++) {
+		res = device_create_file(&pdev->dev,
+					 &data->sysfs_attr[i].dev_attr);
+		if (res) {
+			for (j = 0; j < i; j++)
+				device_remove_file(&pdev->dev,
+					 	&data->sysfs_attr[j].dev_attr);
+			goto err_devreg;
+		}
+	}
+	for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++) {
+		res = device_create_file(&pdev->dev,
+					 &abituguru_sysfs_attr[i].dev_attr);
+		if (res) {
+			for (j = 0; j < i; j++)
+				device_remove_file(&pdev->dev,
+					 &abituguru_sysfs_attr[j].dev_attr);
+			goto err_attr_i;
+		}
+	}
 
 	return 0;
 
+err_attr_i:
+	for (i = 0; i < sysfs_attr_i; i++)
+		device_remove_file(&pdev->dev, &data->sysfs_attr[i].dev_attr);
+err_devreg:
+	hwmon_device_unregister(data->class_dev);
 abituguru_probe_error:
 	kfree(data);
 	return res;

             reply	other threads:[~2006-10-10  6:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-10  6:53 Jeff Garzik [this message]
2006-10-10  7:27 ` [PATCH] hwmon/abituguru: handle sysfs errors Hans de Goede
2006-10-10  9:08   ` Jean Delvare
2006-10-10  9:18     ` Hans de Goede
2006-10-10  9:34       ` Jean Delvare
2006-10-12  4:31         ` Dmitry Torokhov
2006-10-12 15:42           ` Jean Delvare
2006-10-16  3:56             ` Dmitry Torokhov
2006-12-02 11:36       ` Jean Delvare

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=20061010065359.GA21576@havoc.gtf.org \
    --to=jeff@garzik.org \
    --cc=akpm@osdl.org \
    --cc=j.w.r.degoede@hhs.nl \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    /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