public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: Holger Macht <holger@homac.de>
Cc: Matthew Garrett <mjg@redhat.com>,
	Jeff Garzik <jgarzik@redhat.com>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: linux-next: dock_link_device is oopsy
Date: Fri, 17 Feb 2012 15:49:02 -0800 (PST)	[thread overview]
Message-ID: <alpine.LSU.2.00.1202171541040.3155@eggly.anvils> (raw)
In-Reply-To: <20120217230107.GA12929@homac.suse.de>

On Sat, 18 Feb 2012, Holger Macht wrote:
> On Fr 17. Feb - 14:42:31, Hugh Dickins wrote:
> > On Fri, 17 Feb 2012, Holger Macht wrote:
> > > On Fr 17. Feb - 13:46:04, Hugh Dickins wrote:
> > > > Matthew,
> > > > 
> > > > A linux-next oops at bootup in dock_link_device() tells me that you
> > > > were not feeling well when you wrote that and dock_unlink_device():
> > > > I hope you're feeling better now and can rewrite them soon.
> > > 
> > > Andrew Morton experienced a similar problem. What system are you using?
> > > I didn't encounter this problem with the systems I tested with.
> > 
> > The two systems I got that on were both 4-year-old Core2 Duo systems,
> > one an HP quad desktop, one a Fujitsu-Siemens laptop.
> 
> Thanks for the information I think this is really independent from the
> fact if a laptop, or more precicely if a system with dock station/bay is
> used.
> 
> > 
> > > 
> > > Do you actually have a /sys/devices/platform/dock.?/ directory with a
> > > file 'type' that contains 'dock_station'?
> > 
> > I'll have to report back on that this evening, I'm away from them now.
> 
> I actually guess that those systems don't have a
> /sys/devices/platform/dock.? directory at all, which is fine.
> 
> I also think this will fix it, would be great if you could confirm this:
> 
> acpi: Bail out when linking devices and there are no dock stations
> 
> If dock_station_count is zero, we allocate zero memory and don't check
> this at future references. So bail out if there are actually no dock
> stations.
> 
> Signed-off-by: Holger Macht <holger@homac.de>

Certainly won't fix it as is (well, it shifts the crash over into kfree).
This function is expected to return a pointer, not an error or success code.

I've little doubt that returning NULL rather than -ENODEV there would fix
the boot crash; and if you're in a hurry to fix up booting (understandable)
then I suppose that would do for the moment.

But it won't address the rest of the breakage and leakage in here,
which I suspect will reveal more once Matthew has time to look.

Hugh

> ---
>  drivers/acpi/dock.c |   13 ++++++++++---
>  1 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
> index b5e4142..8641912 100644
> --- a/drivers/acpi/dock.c
> +++ b/drivers/acpi/dock.c
> @@ -286,6 +286,9 @@ struct device **dock_link_device(acpi_handle handle)
>  	int ret, dock = 0;
>  	struct device **devices;
>  
> +	if (!dock_station_count)
> +		return -ENODEV;
> +
>  	devices = kmalloc(dock_station_count * sizeof(struct device *),
>  			  GFP_KERNEL);
>  
> @@ -323,9 +326,13 @@ struct device **dock_unlink_device(acpi_handle handle)
>  	struct device *dev = acpi_get_physical_device(handle);
>  	struct dock_station *dock_station;
>  	int dock = 0;
> -	struct device **devices =
> -		kmalloc(dock_station_count * sizeof(struct device *),
> -			GFP_KERNEL);
> +	struct device **devices;
> +
> +	if (!dock_station_count)
> +		return -ENODEV;
> +
> +	devices = kmalloc(dock_station_count * sizeof(struct device *),
> +			  GFP_KERNEL);
>  
>  	if (!dev)
>  		return NULL;
> -- 
> 1.7.7

  reply	other threads:[~2012-02-17 23:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-17 21:46 linux-next: dock_link_device is oopsy Hugh Dickins
2012-02-17 22:29 ` Holger Macht
2012-02-17 22:42   ` Hugh Dickins
2012-02-17 23:01     ` Holger Macht
2012-02-17 23:49       ` Hugh Dickins [this message]
2012-02-18 11:14         ` Holger Macht
2012-02-18 13:05           ` Hillf Danton
2012-02-18 13:26             ` Holger Macht
2012-02-18 13:37               ` Hillf Danton
2012-02-18 14:04                 ` Holger Macht
2012-02-18 14:35                   ` Hillf Danton
2012-02-18 18:46                   ` Hugh Dickins
2012-02-18 19:57                     ` Holger Macht
2012-02-18 21:03                       ` Hugh Dickins
2012-02-18 21:50                         ` Holger Macht
2012-02-21 22:24                       ` Jeff Garzik
2012-02-21 22:30                         ` Holger Macht
2012-02-18  7:52       ` Hugh Dickins

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=alpine.LSU.2.00.1202171541040.3155@eggly.anvils \
    --to=hughd@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=holger@homac.de \
    --cc=jgarzik@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg@redhat.com \
    --cc=sfr@canb.auug.org.au \
    /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