Return-Path: X-Spam-Checker-Version: SpamAssassin X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 Received: from havoc.gtf.org (havoc.gtf.org [69.61.125.42]) by zone4.gcu-squad.org (8.13.5.20060308/8.12.11) with ESMTP id k9A6x32i021352 for ; Tue, 10 Oct 2006 08:59:03 +0200 (CEST) Received: from havoc.gtf.org (havoc.gtf.org [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by havoc.gtf.org (Postfix) with ESMTP id 117371C24EF5; Tue, 10 Oct 2006 02:54:00 -0400 (EDT) Received: (from garzik@localhost) by havoc.gtf.org (8.13.1/8.13.1/Submit) id k9A6rxEW021627; Tue, 10 Oct 2006 02:53:59 -0400 Date: Tue, 10 Oct 2006 02:53:59 -0400 From: Jeff Garzik To: j.w.r.degoede@hhs.nl, khali@linux-fr.org, Andrew Morton , LKML Subject: [PATCH] hwmon/abituguru: handle sysfs errors Message-ID: <20061010065359.GA21576@havoc.gtf.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-Greylist: Delayed for 00:17:40 by milter-greylist-2.1.2 (zone4.gcu-squad.org [217.195.17.234]); Tue, 10 Oct 2006 08:59:03 +0200 (CEST) Status: RO Signed-off-by: Jeff Garzik --- drivers/hwmon/abituguru.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) 2b10f648c8ed965369976eb7925b922ee187ce21 --- linux-2.6.19-git.orig/drivers/hwmon/abituguru.c 2006-12-07 11:39:25.000000000 +0100 +++ linux-2.6.19-git/drivers/hwmon/abituguru.c 2006-12-07 12:26:19.000000000 +0100 @@ -1272,14 +1272,34 @@ 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;