-
Notifications
You must be signed in to change notification settings - Fork 89
serial: core: add checking for platform device #212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
serial: core: add checking for platform device #212
Conversation
@sjasonsmith @gratian Please help to review this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested this? Ideally you would test both that it fixes the crashing you are seeing when pciserial unloads, as well as that it continues to work through surprise removal sequences with cRIO.
drivers/tty/serial/serial_core.c
Outdated
struct serial_port_device *port_dev = port->port_dev; | ||
struct serial_ctrl_device *ctrl_dev = serial_core_get_ctrl_dev(port_dev); | ||
int ctrl_id = port->ctrl_id; | ||
struct platform_device *pdev; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are not using this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@gratian this technique was derived from this old post where a similar issue was resolved elsewhere. |
drivers/tty/serial/serial_core.c
Outdated
serial_base_ctrl_device_remove(new_ctrl_dev); | ||
|
||
if (strncmp(to_platform_device(port->dev)->name, "anon_port", 9) == 0) | ||
if (is_parent_null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: Seeing that if the parent is not NULL anymore after port->dev = &pdev->dev;
above, naming this is_parent_anon_port
or something like that might be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general it looks good. In addition to the improvements suggested @sjasonsmith, and @chaitu236 the commit message could use some tweaking so that in the future we know why the change was needed. It would also let us know that it should be combined with the commit it fixes on the next rebase (it also needs a 'Fixes' tag).
I would reword it to say something like:
Commit 978ca75850f2 ("serial: core: create anonymous parent device")
introduced a NULL pointer dereference by accessing ...
Check whether parent device is of the anon_device_type before getting
its platform_device.
Fixes: 978ca75850f2 ("serial: core: create anonymous parent device")
Signed-off-by: <your signoff>
Commit 978ca75 ("serial: core: create anonymous parent device") introduced a NULL pointer dereference when attempting to access the platform_device structure of the parent. This commit adds a check for parent's device type before getting its platform_device structure. Fixes: 978ca75 ("serial: core: create anonymous parent device") Signed-off-by: Kevin Lim <[email protected]>
731a940
to
0b1452d
Compare
All feedbacks addressed.
|
Check whether parent device is of the anon_device_type before getting its platform_device