serial: core: add checking for platform device#212
Conversation
|
@sjasonsmith @gratian Please help to review this PR |
| 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.
You are not using this.
|
@gratian this technique was derived from this old post where a similar issue was resolved elsewhere. |
| 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.
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.
gratian
left a comment
There was a problem hiding this comment.
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 <khai-wern.lim@ni.com>
731a940 to
0b1452d
Compare
|
All feedbacks addressed. |
Check whether parent device is of the anon_device_type before getting its platform_device