From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755174Ab2BQXBM (ORCPT ); Fri, 17 Feb 2012 18:01:12 -0500 Received: from cantor2.suse.de ([195.135.220.15]:60733 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753287Ab2BQXBL (ORCPT ); Fri, 17 Feb 2012 18:01:11 -0500 Date: Sat, 18 Feb 2012 00:01:07 +0100 From: Holger Macht To: Hugh Dickins Cc: Matthew Garrett , Jeff Garzik , Stephen Rothwell , linux-kernel@vger.kernel.org, Andrew Morton Subject: Re: linux-next: dock_link_device is oopsy Message-ID: <20120217230107.GA12929@homac.suse.de> References: <20120217222922.GA2741@homac.suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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