mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-09-21 04:00:29 +00:00
uwb: init beacon cache entry before registering uwb device
commit 675f0ab2fe
upstream.
Make sure the uwb_dev->bce entry is set before calling uwb_dev_add in
uwbd_dev_onair so that usermode will only see the device after it is
properly initialized. This fixes a kernel panic that can occur if
usermode tries to access the IEs sysfs attribute of a UWB device before
the driver has had a chance to set the beacon cache entry.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[lizf: Backported to 3.4: adjust context]
Signed-off-by: Zefan Li <lizefan@huawei.com>
This commit is contained in:
parent
0d69cbb4a9
commit
96eb53749f
|
@ -441,16 +441,19 @@ void uwbd_dev_onair(struct uwb_rc *rc, struct uwb_beca_e *bce)
|
||||||
uwb_dev->mac_addr = *bce->mac_addr;
|
uwb_dev->mac_addr = *bce->mac_addr;
|
||||||
uwb_dev->dev_addr = bce->dev_addr;
|
uwb_dev->dev_addr = bce->dev_addr;
|
||||||
dev_set_name(&uwb_dev->dev, macbuf);
|
dev_set_name(&uwb_dev->dev, macbuf);
|
||||||
|
|
||||||
|
/* plug the beacon cache */
|
||||||
|
bce->uwb_dev = uwb_dev;
|
||||||
|
uwb_dev->bce = bce;
|
||||||
|
uwb_bce_get(bce); /* released in uwb_dev_sys_release() */
|
||||||
|
|
||||||
result = uwb_dev_add(uwb_dev, &rc->uwb_dev.dev, rc);
|
result = uwb_dev_add(uwb_dev, &rc->uwb_dev.dev, rc);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
dev_err(dev, "new device %s: cannot instantiate device\n",
|
dev_err(dev, "new device %s: cannot instantiate device\n",
|
||||||
macbuf);
|
macbuf);
|
||||||
goto error_dev_add;
|
goto error_dev_add;
|
||||||
}
|
}
|
||||||
/* plug the beacon cache */
|
|
||||||
bce->uwb_dev = uwb_dev;
|
|
||||||
uwb_dev->bce = bce;
|
|
||||||
uwb_bce_get(bce); /* released in uwb_dev_sys_release() */
|
|
||||||
dev_info(dev, "uwb device (mac %s dev %s) connected to %s %s\n",
|
dev_info(dev, "uwb device (mac %s dev %s) connected to %s %s\n",
|
||||||
macbuf, devbuf, rc->uwb_dev.dev.parent->bus->name,
|
macbuf, devbuf, rc->uwb_dev.dev.parent->bus->name,
|
||||||
dev_name(rc->uwb_dev.dev.parent));
|
dev_name(rc->uwb_dev.dev.parent));
|
||||||
|
@ -458,6 +461,8 @@ void uwbd_dev_onair(struct uwb_rc *rc, struct uwb_beca_e *bce)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error_dev_add:
|
error_dev_add:
|
||||||
|
bce->uwb_dev = NULL;
|
||||||
|
uwb_bce_put(bce);
|
||||||
kfree(uwb_dev);
|
kfree(uwb_dev);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue