[PATCH RESEND] gadgetfs: Initialize CHIP to NULL before UDC probe

2014-03-27 Thread Lubomir Rintel
Otherwise the value from the last probe would be retained that possibly is
freed since (the UDC is removed) and therefore no longer relevant. Reproducible
with the dummy UDC:

  modprobe dummy_hcd
  mount -t gadgetfs gadgetfs /dev/gadget
  umount /dev/gadget
  rmmod dummy_hcd
  mount -t gadgetfs gadgetfs /dev/gadget

BUG: unable to handle kernel paging request at a066fd9d
Call Trace:
 [] ? d_alloc_name+0x22/0x50
 [] ? selinux_d_instantiate+0x1c/0x20
 [] gadgetfs_create_file+0x27/0xa0 [gadgetfs]
 [] ? setup_req.isra.4+0x80/0x80 [gadgetfs]
 [] gadgetfs_fill_super+0x13c/0x180 [gadgetfs]
 [] mount_single+0x92/0xc0
 [] gadgetfs_mount+0x18/0x20 [gadgetfs]
 [] mount_fs+0x39/0x1b0
 [] ? __alloc_percpu+0x10/0x20
 [] vfs_kern_mount+0x63/0xf0
 [] do_mount+0x23e/0xac0
 [] ? strndup_user+0x4b/0xf0
 [] SyS_mount+0x83/0xc0
 [] system_call_fastpath+0x16/0x1b

Signed-off-by: Lubomir Rintel 
---
 drivers/usb/gadget/inode.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index b94c049..ee15628 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -2046,6 +2046,7 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, 
int silent)
return -ESRCH;
 
/* fake probe to determine $CHIP */
+   CHIP = NULL;
usb_gadget_probe_driver(_driver);
if (!CHIP)
return -ENODEV;
-- 
1.8.5.3

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


[PATCH RESEND] gadgetfs: Initialize CHIP to NULL before UDC probe

2014-03-27 Thread Lubomir Rintel
Otherwise the value from the last probe would be retained that possibly is
freed since (the UDC is removed) and therefore no longer relevant. Reproducible
with the dummy UDC:

  modprobe dummy_hcd
  mount -t gadgetfs gadgetfs /dev/gadget
  umount /dev/gadget
  rmmod dummy_hcd
  mount -t gadgetfs gadgetfs /dev/gadget

BUG: unable to handle kernel paging request at a066fd9d
Call Trace:
 [811d0cd2] ? d_alloc_name+0x22/0x50
 [812b74dc] ? selinux_d_instantiate+0x1c/0x20
 [a067d687] gadgetfs_create_file+0x27/0xa0 [gadgetfs]
 [a067da70] ? setup_req.isra.4+0x80/0x80 [gadgetfs]
 [a067dbac] gadgetfs_fill_super+0x13c/0x180 [gadgetfs]
 [811bc832] mount_single+0x92/0xc0
 [a067d0f8] gadgetfs_mount+0x18/0x20 [gadgetfs]
 [811bc8f9] mount_fs+0x39/0x1b0
 [8116b220] ? __alloc_percpu+0x10/0x20
 [811d6da3] vfs_kern_mount+0x63/0xf0
 [811d93be] do_mount+0x23e/0xac0
 [811660eb] ? strndup_user+0x4b/0xf0
 [811d9f63] SyS_mount+0x83/0xc0
 [81695b69] system_call_fastpath+0x16/0x1b

Signed-off-by: Lubomir Rintel lkund...@v3.sk
---
 drivers/usb/gadget/inode.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index b94c049..ee15628 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -2046,6 +2046,7 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, 
int silent)
return -ESRCH;
 
/* fake probe to determine $CHIP */
+   CHIP = NULL;
usb_gadget_probe_driver(probe_driver);
if (!CHIP)
return -ENODEV;
-- 
1.8.5.3

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