Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d92d1f05 authored by Arun Kumar Neelakantam's avatar Arun Kumar Neelakantam
Browse files

TTY: msm_smd_tty: Fix clean up tty devices in fail case



Smd tty device index read by old device tree label causing the
clean-up code to exit abruptly and resulting in a crash during
re-registration with fall back option.

Read the smd tty device index with proper label and do the clean-up
complete.

CRs-Fixed: 669452
Change-Id: Ib317a035e51ca8040b199bc1a9986b731e59410d
Signed-off-by: default avatarArun Kumar Neelakantam <aneela@codeaurora.org>
parent c3c6d40a
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -1049,13 +1049,19 @@ error:
	/* Unregister tty platform devices */
	for_each_child_of_node(pdev->dev.of_node, node) {

		key = "qcom,smdtty-dev-idx";
		ret = of_property_read_u32(node, key, &idx);
		if (ret || idx >= MAX_SMD_TTYS)
		ret = of_alias_get_id(node, "smd");
		SMD_TTY_INFO("%s:Removing smd%d\n", __func__, ret);

		if (ret < 0 || ret >= MAX_SMD_TTYS)
			goto out;
		if (smd_tty[idx].device_ptr)
		idx = ret;

		if (smd_tty[idx].device_ptr) {
			device_remove_file(smd_tty[idx].device_ptr,
						&dev_attr_open_timeout);
			tty_unregister_device(smd_tty_driver, idx);
		}
	}
out:
	tty_unregister_driver(smd_tty_driver);
	put_tty_driver(smd_tty_driver);