lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <1427123347-22651-2-git-send-email-b.zolnierkie@samsung.com>
Date:	Mon, 23 Mar 2015 16:09:04 +0100
From:	Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>
To:	Lee Jones <lee.jones@...aro.org>,
	Samuel Ortiz <sameo@...ux.intel.com>
Cc:	Johan Hovold <johan@...nel.org>,
	Support Opensource <support.opensource@...semi.com>,
	Milo Kim <milo.kim@...com>,
	patches@...nsource.wolfsonmicro.com,
	Fabio Estevam <fabio.estevam@...escale.com>,
	Marek Szyprowski <m.szyprowski@...sung.com>,
	linux-kernel@...r.kernel.org, b.zolnierkie@...sung.com,
	stable@...r.kernel.org
Subject: [PATCH v3 1/4] mfd: max8997: Fix platform device ids to avoid probe
 failure

Commit 6e3f62f0793e ("mfd: core: Fix platform-device id generation")
changed the way platform device ids are generated from mfd id base and
cell ids in mfd_add_device().  Unfortunately the change in question
breaks mfd drivers which are using mfd_add_devices() with mfd id base
equal to -1 and non-zero cell ids (used to distinguish cells with
the same name field).  The result is that mfd core tries to register
platform devices with the same name which obviously fails and leads
to mfd device probe failure.

Relevant error messages in case of MAX8997 PMIC driver:

[    0.911674] ------------[ cut here ]------------
[    0.911706] WARNING: CPU: 0 PID: 1 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x54/0x70()
[    0.911718] sysfs: cannot create duplicate filename '/devices/13860000.i2c/i2c-0/0-0066/max8997-led'
[    0.911725] Modules linked in:
[    0.911742] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.18.0-rc1-00027-g6e3f62f #1557
[    0.911782] [<c0013cb4>] (unwind_backtrace) from [<c0010d10>] (show_stack+0x10/0x14)
[    0.911809] [<c0010d10>] (show_stack) from [<c04619c8>] (dump_stack+0x68/0xb8)
[    0.911837] [<c04619c8>] (dump_stack) from [<c0020c80>] (warn_slowpath_common+0x64/0x84)
[    0.911854] [<c0020c80>] (warn_slowpath_common) from [<c0020d34>] (warn_slowpath_fmt+0x30/0x40)
[    0.911871] [<c0020d34>] (warn_slowpath_fmt) from [<c011ec50>] (sysfs_warn_dup+0x54/0x70)
[    0.911887] [<c011ec50>] (sysfs_warn_dup) from [<c011ecf4>] (sysfs_create_dir_ns+0x88/0x90)
[    0.911910] [<c011ecf4>] (sysfs_create_dir_ns) from [<c01d5524>] (kobject_add_internal+0x9c/0x2c0)
[    0.911926] [<c01d5524>] (kobject_add_internal) from [<c01d58d0>] (kobject_add+0x4c/0x94)
[    0.911950] [<c01d58d0>] (kobject_add) from [<c026f65c>] (device_add+0xb8/0x4d8)
[    0.911969] [<c026f65c>] (device_add) from [<c027330c>] (platform_device_add+0x114/0x214)
[    0.911996] [<c027330c>] (platform_device_add) from [<c028d0f0>] (mfd_add_device+0x240/0x328)
[    0.912013] [<c028d0f0>] (mfd_add_device) from [<c028d3d0>] (mfd_add_devices+0xa4/0xe8)
[    0.912030] [<c028d3d0>] (mfd_add_devices) from [<c028e3b0>] (max8997_i2c_probe+0x150/0x230)
[    0.912056] [<c028e3b0>] (max8997_i2c_probe) from [<c0329114>] (i2c_device_probe+0xe8/0x120)
[    0.912076] [<c0329114>] (i2c_device_probe) from [<c0271cf0>] (driver_probe_device+0x114/0x234)
[    0.912094] [<c0271cf0>] (driver_probe_device) from [<c0270630>] (bus_for_each_drv+0x5c/0x88)
[    0.912109] [<c0270630>] (bus_for_each_drv) from [<c0271ba8>] (device_attach+0x70/0x88)
[    0.912124] [<c0271ba8>] (device_attach) from [<c0271304>] (bus_probe_device+0x84/0xa8)
[    0.912138] [<c0271304>] (bus_probe_device) from [<c026f94c>] (device_add+0x3a8/0x4d8)
[    0.912153] [<c026f94c>] (device_add) from [<c03298c0>] (i2c_new_device+0xfc/0x16c)
[    0.912167] [<c03298c0>] (i2c_new_device) from [<c0329dd0>] (i2c_register_adapter+0x27c/0x490)
[    0.912186] [<c0329dd0>] (i2c_register_adapter) from [<c032f184>] (s3c24xx_i2c_probe+0x200/0x4dc)
[    0.912205] [<c032f184>] (s3c24xx_i2c_probe) from [<c027310c>] (platform_drv_probe+0x48/0x98)
[    0.912219] [<c027310c>] (platform_drv_probe) from [<c0271cf0>] (driver_probe_device+0x114/0x234)
[    0.912232] [<c0271cf0>] (driver_probe_device) from [<c0271e9c>] (__driver_attach+0x8c/0x90)
[    0.912246] [<c0271e9c>] (__driver_attach) from [<c02706b0>] (bus_for_each_dev+0x54/0x88)
[    0.912262] [<c02706b0>] (bus_for_each_dev) from [<c02714f4>] (bus_add_driver+0xd8/0x1cc)
[    0.912275] [<c02714f4>] (bus_add_driver) from [<c02724bc>] (driver_register+0x78/0xf4)
[    0.912291] [<c02724bc>] (driver_register) from [<c0008924>] (do_one_initcall+0x80/0x1c4)
[    0.912312] [<c0008924>] (do_one_initcall) from [<c062cd20>] (kernel_init_freeable+0x100/0x1cc)
[    0.912330] [<c062cd20>] (kernel_init_freeable) from [<c045da50>] (kernel_init+0x8/0xe4)
[    0.912348] [<c045da50>] (kernel_init) from [<c000e5b8>] (ret_from_fork+0x14/0x3c)
[    0.912370] ---[ end trace ca08768d4d1efd62 ]---
[    0.912382] ------------[ cut here ]------------
[    0.912402] WARNING: CPU: 0 PID: 1 at lib/kobject.c:240 kobject_add_internal+0x238/0x2c0()
[    0.912411] kobject_add_internal failed for max8997-led with -EEXIST, don't try to register things with the same name in th
e same directory.
[    0.912418] Modules linked in:
[    0.912433] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G        W      3.18.0-rc1-00027-g6e3f62f #1557
[    0.912458] [<c0013cb4>] (unwind_backtrace) from [<c0010d10>] (show_stack+0x10/0x14)
[    0.912479] [<c0010d10>] (show_stack) from [<c04619c8>] (dump_stack+0x68/0xb8)
[    0.912502] [<c04619c8>] (dump_stack) from [<c0020c80>] (warn_slowpath_common+0x64/0x84)
[    0.912519] [<c0020c80>] (warn_slowpath_common) from [<c0020d34>] (warn_slowpath_fmt+0x30/0x40)
[    0.912536] [<c0020d34>] (warn_slowpath_fmt) from [<c01d56c0>] (kobject_add_internal+0x238/0x2c0)
[    0.912553] [<c01d56c0>] (kobject_add_internal) from [<c01d58d0>] (kobject_add+0x4c/0x94)
[    0.912572] [<c01d58d0>] (kobject_add) from [<c026f65c>] (device_add+0xb8/0x4d8)
[    0.912588] [<c026f65c>] (device_add) from [<c027330c>] (platform_device_add+0x114/0x214)
[    0.912611] [<c027330c>] (platform_device_add) from [<c028d0f0>] (mfd_add_device+0x240/0x328)
[    0.912628] [<c028d0f0>] (mfd_add_device) from [<c028d3d0>] (mfd_add_devices+0xa4/0xe8)
[    0.912643] [<c028d3d0>] (mfd_add_devices) from [<c028e3b0>] (max8997_i2c_probe+0x150/0x230)
[    0.912665] [<c028e3b0>] (max8997_i2c_probe) from [<c0329114>] (i2c_device_probe+0xe8/0x120)
[    0.912682] [<c0329114>] (i2c_device_probe) from [<c0271cf0>] (driver_probe_device+0x114/0x234)
[    0.912700] [<c0271cf0>] (driver_probe_device) from [<c0270630>] (bus_for_each_drv+0x5c/0x88)
[    0.912714] [<c0270630>] (bus_for_each_drv) from [<c0271ba8>] (device_attach+0x70/0x88)
[    0.912729] [<c0271ba8>] (device_attach) from [<c0271304>] (bus_probe_device+0x84/0xa8)
[    0.912743] [<c0271304>] (bus_probe_device) from [<c026f94c>] (device_add+0x3a8/0x4d8)
[    0.912758] [<c026f94c>] (device_add) from [<c03298c0>] (i2c_new_device+0xfc/0x16c)
[    0.912771] [<c03298c0>] (i2c_new_device) from [<c0329dd0>] (i2c_register_adapter+0x27c/0x490)
[    0.912789] [<c0329dd0>] (i2c_register_adapter) from [<c032f184>] (s3c24xx_i2c_probe+0x200/0x4dc)
[    0.912805] [<c032f184>] (s3c24xx_i2c_probe) from [<c027310c>] (platform_drv_probe+0x48/0x98)
[    0.912820] [<c027310c>] (platform_drv_probe) from [<c0271cf0>] (driver_probe_device+0x114/0x234)
[    0.912833] [<c0271cf0>] (driver_probe_device) from [<c0271e9c>] (__driver_attach+0x8c/0x90)
[    0.912847] [<c0271e9c>] (__driver_attach) from [<c02706b0>] (bus_for_each_dev+0x54/0x88)
[    0.912862] [<c02706b0>] (bus_for_each_dev) from [<c02714f4>] (bus_add_driver+0xd8/0x1cc)
[    0.912875] [<c02714f4>] (bus_add_driver) from [<c02724bc>] (driver_register+0x78/0xf4)
[    0.912889] [<c02724bc>] (driver_register) from [<c0008924>] (do_one_initcall+0x80/0x1c4)
[    0.912908] [<c0008924>] (do_one_initcall) from [<c062cd20>] (kernel_init_freeable+0x100/0x1cc)
[    0.912925] [<c062cd20>] (kernel_init_freeable) from [<c045da50>] (kernel_init+0x8/0xe4)
[    0.912942] [<c045da50>] (kernel_init) from [<c000e5b8>] (ret_from_fork+0x14/0x3c)
[    0.912952] ---[ end trace ca08768d4d1efd63 ]---
[    0.920721] max8997 0-0066: failed to add MFD devices -17
[    0.921553] max8997: probe of 0-0066 failed with error -17

Change mfd_add_devices() mfd id base from -1 to PLATFORM_DEVID_AUTO
to fix the issue.

This fix was tested on Exynos4210 Origen board which is using MAX8997
PMIC (it also fixes Exynos cpufreq support which was broken because
vdd_arm regulator was not available due to MAX8997 PMIC probe failure).

Fixes: 6e3f62f0793e ("mfd: core: Fix platform-device id generation")
Cc: Johan Hovold <johan@...nel.org>
Cc: <stable@...r.kernel.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>
---
 drivers/mfd/max8997.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index 595364e..1c3cb75 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -234,7 +234,7 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
 
 	max8997_irq_init(max8997);
 
-	ret = mfd_add_devices(max8997->dev, -1, max8997_devs,
+	ret = mfd_add_devices(max8997->dev, PLATFORM_DEVID_AUTO, max8997_devs,
 			ARRAY_SIZE(max8997_devs),
 			NULL, 0, NULL);
 	if (ret < 0) {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ