Re: linux-next: dock_link_device is oopsy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

You are correct, no /sys/devices/platform/dock.? directory on those.

> 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@xxxxxxxx>
> ---
>  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;

If I change your -ENODEV to NULL (here and in unlink, though I didn't
check if that gets called), yes, that "fixes" the crash at boot.

But note that in each case you already did an acpi_get_physical_device:
if the existing code was correct in this regard, then you ought to be
doing a put_device(dev) before returning.

Or better reorder it all.


> +
>  	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
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at

[Other Archives]     [Linux Kernel Newbies]     [Linux Driver Development]     [Fedora Kernel]     [Linux Kernel Testers]     [Linux SH]     [Linux Omap]     [Linux Kbuild]     [Linux Tape]     [Linux Input]     [Linux Kernel Janitors]     [Linux Kernel Packagers]     [Linux Doc]     [Linux Man Pages]     [Linux API]     [Linux Memory Management]     [Linux Modules]     [Linux Standards]     [Kernel Announce]     [Netdev]     [Git]     [Linux PCI]     Linux CAN Development     [Linux I2C]     [Linux RDMA]     [Linux NUMA]     [Netfilter]     [Netfilter Devel]     [SELinux]     [Bugtraq]     [FIO]     [Linux Perf Users]     [Linux Serial]     [Linux PPP]     [Linux ISDN]     [Linux Next]     [Kernel Stable Commits]     [Linux Tip Commits]     [Kernel MM Commits]     [Linux Security Module]     [Filesystem Development]     [Ext3 Filesystem]     [Linux bcache]     [Ext4 Filesystem]     [Linux BTRFS]     [Linux CEPH Filesystem]     [Linux XFS]     [XFS]     [Linux NFS]     [Linux CIFS]     [Ecryptfs]     [Linux NILFS]     [Linux Cachefs]     [Reiser FS]     [Initramfs]     [Linux FB Devel]     [Linux OpenGL]     [DRI Devel]     [Fastboot]     [Linux RT Users]     [Linux RT Stable]     [eCos]     [Corosync]     [Linux Clusters]     [LVS Devel]     [Hot Plug]     [Linux Virtualization]     [KVM]     [KVM PPC]     [KVM ia64]     [Linux Containers]     [Linux Hexagon]     [Linux Cgroups]     [Util Linux]     [Wireless]     [Linux Bluetooth]     [Bluez Devel]     [Ethernet Bridging]     [Embedded Linux]     [Barebox]     [Linux MMC]     [Linux IIO]     [Sparse]     [Smatch]     [Linux Arch]     [x86 Platform Driver]     [Linux ACPI]     [Linux IBM ACPI]     [LM Sensors]     [CPU Freq]     [Linux Power Management]     [Linmodems]     [Linux DCCP]     [Linux SCTP]     [ALSA Devel]     [Linux USB]     [Linux PA RISC]     [Linux Samsung SOC]     [MIPS Linux]     [IBM S/390 Linux]     [ARM Linux]     [ARM Kernel]     [ARM MSM]     [Tegra Devel]     [Sparc Linux]     [Linux Security]     [Linux Sound]     [Linux Media]     [Video 4 Linux]     [Linux IRDA Users]     [Linux for the blind]     [Linux RAID]     [Linux ATA RAID]     [Device Mapper]     [Linux SCSI]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Linux IDE]     [Linux SMP]     [Linux AXP]     [Linux Alpha]     [Linux M68K]     [Linux ia64]     [Linux 8086]     [Linux x86_64]     [Linux Config]     [Linux Apps]     [Linux MSDOS]     [Linux X.25]     [Linux Crypto]     [DM Crypt]     [Linux Trace Users]     [Linux Btrace]     [Linux Watchdog]     [Utrace Devel]     [Linux C Programming]     [Linux Assembly]     [Dash]     [DWARVES]     [Hail Devel]     [Linux Kernel Debugger]     [Linux gcc]     [Gcc Help]     [X.Org]     [Wine]

Add to Google Powered by Linux

[Older Kernel Discussion]     [Yosemite National Park Forum]     [Large Format Photos]     [Gimp]     [Yosemite Photos]     [Stuff]