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

Commit 2cad996e authored by Eric Holmberg's avatar Eric Holmberg
Browse files

TTY: msm_smd_tty: Add warning to driver removal function



The current implementation of smd_tty_remove_driver does not check to
see if a matching driver instance is found before attempting to
unregister the driver. This could lead to a silent failure or an attempt
to remove a driver that does not exist.

Add a flag that indicates if a matching driver is found in the list
before removal is attempted. If no drivers are found, an error message
is logged.

Change-Id: I30f067b11dbe736ae065c5d4fbe30ca5c0645bb6
Signed-off-by: default avatarEric Holmberg <eholmber@codeaurora.org>
parent 22f171b1
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -492,6 +492,7 @@ exit:
static void smd_tty_remove_driver(struct smd_tty_info *info)
{
	struct smd_tty_pfdriver *smd_tty_pfdriverp;
	bool found_item = false;

	if (!info) {
		pr_err("%s on a NULL device\n", __func__);
@@ -504,6 +505,7 @@ static void smd_tty_remove_driver(struct smd_tty_info *info)
	list_for_each_entry(smd_tty_pfdriverp, &smd_tty_pfdriver_list, list) {
		if (!strcmp(smd_tty_pfdriverp->driver.driver.name,
					info->ch_name)) {
			found_item = true;
			SMD_TTY_INFO("%s:%s Platform driver cnt:%d\n",
				__func__, info->ch_name,
				smd_tty_pfdriverp->ref_cnt);
@@ -514,8 +516,11 @@ static void smd_tty_remove_driver(struct smd_tty_info *info)
			break;
		}
	}
	if (!found_item)
		SMD_TTY_ERR("%s:%s No item found in list.\n",
			__func__, info->ch_name);

	if (smd_tty_pfdriverp->ref_cnt == 0) {
	if (found_item && smd_tty_pfdriverp->ref_cnt == 0) {
		platform_driver_unregister(&smd_tty_pfdriverp->driver);
		smd_tty_pfdriverp->driver.probe = NULL;
		list_del(&smd_tty_pfdriverp->list);