With commit 0998d0631001288a5974afc0b2a5f568bcdecb4d, driver_data is cleared after driver is unbound. So from now on, it's not suitable to maintain serial port private data by driver core, because some usb serial drivers, such as usb_wwan, need retrieve port private data(in disconnect() and release() callbacks ) even after the driver is unbound. This will cause NULL pointer reference oops.
Let usb_serial_port maintain port private data to fix the issue. Signed-off-by: Huajun Li <huajun.li....@gmail.com> --- include/linux/usb/serial.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index 86c0b45..385b9c3 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h @@ -70,6 +70,9 @@ * @throttled: nonzero if the read urb is inactive to throttle the device * @throttle_req: nonzero if the tty wants to throttle us * @dev: pointer to the serial device + * @private: place to put any port private data. + * Use usb_get_serial_port_data() and + * usb_set_serial_port_data() to access this. * * This structure is used by the usb-serial core and drivers for the specific * ports of a device. @@ -117,19 +120,20 @@ struct usb_serial_port { char throttle_req; unsigned long sysrq; /* sysrq timeout */ struct device dev; + void *private; }; #define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev) /* get and set the port private data pointer helper functions */ static inline void *usb_get_serial_port_data(struct usb_serial_port *port) { - return dev_get_drvdata(&port->dev); + return port->private; } static inline void usb_set_serial_port_data(struct usb_serial_port *port, void *data) { - dev_set_drvdata(&port->dev, data); + port->private = data; } /** -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html