public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jean Delvare" <khali@linux-fr.org>
To: akpm@osdl.org,
	ajwade@cpe00095b3131a0-cm0011ae8cd564.cpe.net.cable.rogers.com
Cc: linux-kernel@vger.kernel.org, "Greg KH" <greg@kroah.com>,
	"Mark M. Hoffman" <mhoffman@lightlink.com>
Subject: Re: BUG in i2c_detach_client
Date: Thu, 9 Jun 2005 09:47:23 +0200 (CEST)	[thread overview]
Message-ID: <JctXv2LZ.1118303243.5186830.khali@localhost> (raw)
In-Reply-To: <20050608142631.7e956792.akpm@osdl.org>


Hi Andrew, Andrew, all,

[Adding Mark M. Hoffman in the loop, as the author and recent modifier of
the asb100 driver.]

> From: Andrew Morton <akpm@osdl.org>
>
> Fix error backing-out code in asb100.c
>
> Cc: Greg KH <greg@kroah.com>
> Signed-off-by: Andrew Morton <akpm@osdl.org>
> (...)
> --- 25/drivers/i2c/chips/asb100.c~asb100-fix
> +++ 25-akpm/drivers/i2c/chips/asb100.c
> @@ -690,18 +690,20 @@ static int asb100_detect_subclients(stru
>  	if ((err = i2c_attach_client(data->lm75[0]))) {
>  		dev_err(&new_client->dev, "subclient %d registration "
>  			"at address 0x%x failed.\n", i, data->lm75[0]->addr);
> -		goto ERROR_SC_2;
> +		goto ERROR_SC_3;
>  	}
> 
>  	if ((err = i2c_attach_client(data->lm75[1]))) {
>  		dev_err(&new_client->dev, "subclient %d registration "
>  			"at address 0x%x failed.\n", i, data->lm75[1]->addr);
> -		goto ERROR_SC_3;
> +		goto ERROR_SC_4;
>  	}
> 
>  	return 0;
>
>  /* Undo inits in case of errors */
> +ERROR_SC_4:
> +	i2c_detach_client(data->lm75[1]);
>  ERROR_SC_3:
>  	i2c_detach_client(data->lm75[0]);
>  ERROR_SC_2:

This patch looks broken to me, please discard it. You do not want to call
i2c_detach_client when the corresponding i2c_attach_client failed. The
original code was fine in that respect. I don't think there is any
problem in the asb100_detect_subclients() function.

I do however think that there is a problem in the asb100_detect()
function, where a call to i2c_detach client() is missing:

ERROR3:
	i2c_detach_client(data->lm75[1]); <-- HERE
	i2c_detach_client(data->lm75[0]);
	kfree(data->lm75[1]);
	kfree(data->lm75[0]);

If we take that error path, it means that both subclients have been
successfully attached, thus need proper detach.

The reason why the bug triggered on Andrew (James Wade) is probably that
hwmon_device_register() failed, due to an order problem in a Makefile.
See http://lkml.org/lkml/2005/6/8/338, which has an explanation and a
patch fixing it (I think).

This still doesn't explain why the error path triggers the BUG(), and
although applying the aforementioned patch will probably get the driver
working, I'd really like to understand what's going on there.

Thanks,
--
Jean Delvare

  parent reply	other threads:[~2005-06-09  7:58 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-07 11:29 2.6.12-rc6-mm1 Andrew Morton
2005-06-07 14:24 ` 2.6.12-rc6-mm1 Wolfgang Wander
2005-06-07 14:49   ` 2.6.12-rc6-mm1 Wolfgang Wander
2005-06-07 14:48 ` 2.6.12-rc6-mm1 Brice Goglin
2005-06-07 20:59 ` 2.6.12-rc6-mm1: rio confusion Adrian Bunk
2005-06-07 21:38   ` Matt Porter
2005-06-07 23:15 ` 2.6.12-rc6-mm1 Francois Romieu
2005-06-08  1:59 ` 2.6.12-rc6-mm1 Søren Lott
2005-06-08  5:53   ` 2.6.12-rc6-mm1 Jean Delvare
2005-06-08  7:08     ` 2.6.12-rc6-mm1 Søren Lott
2005-06-09  3:47       ` [lm-sensors] 2.6.12-rc6-mm1 Mark M. Hoffman
2005-06-08 14:22 ` 2.6.12-rc6-mm1 Andy Whitcroft
2005-06-08 20:01   ` 2.6.12-rc6-mm1 Andrew Morton
2005-06-08 23:14     ` 2.6.12-rc6-mm1 Martin J. Bligh
2005-06-08 23:22       ` 2.6.12-rc6-mm1 Andrew Morton
2005-06-08 23:34         ` 2.6.12-rc6-mm1 Martin J. Bligh
2005-06-09  7:17           ` 2.6.12-rc6-mm1 Kirill Korotaev
2005-06-09 13:38             ` 2.6.12-rc6-mm1 Martin J. Bligh
2005-06-10 12:12               ` 2.6.12-rc6-mm1 Kirill Korotaev
2005-06-09  4:27   ` 2.6.12-rc6-mm1 Andrey Panin
2005-06-09 13:12     ` 2.6.12-rc6-mm1 Andy Whitcroft
2005-06-08 14:33 ` BUG in i2c_detach_client Andrew James Wade
2005-06-08 16:21   ` Jean Delvare
2005-06-08 21:26   ` Andrew Morton
2005-06-08 22:56     ` Andrew James Wade
2005-06-08 23:32       ` Andrew Morton
2005-06-09  7:52         ` Jean Delvare
2005-06-09  7:47     ` Jean Delvare [this message]
2005-06-09 11:05       ` Andrew James Wade
2005-06-09 13:32       ` Andrew James Wade
2005-06-09 15:57         ` Jean Delvare
2005-06-10  5:58           ` Greg KH
2005-06-10  7:08             ` Jean Delvare
2005-06-11 11:51 ` 2.6.12-rc6-mm1 Benoit Boissinot
2005-06-18 22:39 ` 2.6.12-rc6-mm1 Richard Purdie
2005-06-18 22:44   ` 2.6.12-rc6-mm1 Andrew Morton
2005-06-18 22:57     ` 2.6.12-rc6-mm1 Richard Purdie
2005-06-18 23:11       ` 2.6.12-rc6-mm1 Richard Purdie
2005-06-18 23:18   ` 2.6.12-rc6-mm1 Russell King
2005-06-19  1:20     ` 2.6.12-rc6-mm1 Richard Purdie
2005-06-19  9:02       ` 2.6.12-rc6-mm1 Russell King
2005-06-19  9:11         ` 2.6.12-rc6-mm1 Russell King
2005-06-19 17:12           ` 2.6.12-rc6-mm1 Richard Purdie
2005-06-19 17:39             ` 2.6.12-rc6-mm1 Russell King
2005-06-19 18:25               ` 2.6.12-rc6-mm1 Richard Purdie
2005-06-19 18:56                 ` 2.6.12-rc6-mm1 Russell King
2005-06-21 13:20 ` 2.6.12-rc6-mm1 Dominik Karall
2005-06-24 21:27   ` 2.6.12-rc6-mm1 Alexey Dobriyan
2005-07-29  4:54   ` 2.6.12-rc6-mm1 Andrew Morton
2005-07-29 13:39     ` 2.6.12-rc6-mm1 Dominik Karall
2005-07-29 18:22       ` 2.6.12-rc6-mm1 Andrew Morton
2005-07-29 21:19         ` 2.6.12-rc6-mm1 Dominik Karall
2005-07-29 21:27           ` 2.6.12-rc6-mm1 Andrew Morton
2005-07-29 21:37             ` 2.6.12-rc6-mm1 Dominik Karall
2005-08-04 19:44               ` 2.6.12-rc6-mm1 Andrew Morton
2005-08-04 22:28                 ` 2.6.12-rc6-mm1 Andrew Morton
2005-08-04 22:44                   ` 2.6.12-rc6-mm1 Dominik Karall
2005-08-05 10:48                   ` [patch] preempt-trace.patch Ingo Molnar
2005-08-05 11:44                     ` Dominik Karall
2005-08-05 15:13                       ` [patch] preempt-trace-fixes.patch Ingo Molnar
2005-08-05 18:14                         ` Dominik Karall
2005-08-05 14:26                     ` [patch] preempt-trace.patch (mono preempt-trace) Dominik Karall
2005-08-05 15:22                       ` Ingo Molnar
2005-08-05 17:58                         ` Dominik Karall
2005-08-05 18:46                           ` Hugh Dickins
2005-08-05 19:23                             ` Dominik Karall
2005-08-05 20:04                               ` Ingo Molnar
2005-08-05 20:48                                 ` Dominik Karall
2005-08-05 18:05                         ` Andrew Morton
2005-08-05 20:08                           ` Ingo Molnar
2005-08-05 20:13                           ` Ingo Molnar

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=JctXv2LZ.1118303243.5186830.khali@localhost \
    --to=khali@linux-fr.org \
    --cc=ajwade@cpe00095b3131a0-cm0011ae8cd564.cpe.net.cable.rogers.com \
    --cc=akpm@osdl.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhoffman@lightlink.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