diff options
author | Eric Holmberg <eholmber@codeaurora.org> | 2014-02-11 16:26:44 -0700 |
---|---|---|
committer | Eric Holmberg <eholmber@codeaurora.org> | 2014-02-12 18:24:11 -0700 |
commit | 2cad996e0d42e6cd7ef8ad421c443dbf58b3d673 (patch) | |
tree | 02548079bd7feaf839c43a773c214b424e47e808 /drivers/tty | |
parent | 22f171b17bc4a29941b0a432998480f7598ffade (diff) |
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: Eric Holmberg <eholmber@codeaurora.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/serial/msm_smd_tty.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/tty/serial/msm_smd_tty.c b/drivers/tty/serial/msm_smd_tty.c index 8cdf8bd636ca..1af5183ee03a 100644 --- a/drivers/tty/serial/msm_smd_tty.c +++ b/drivers/tty/serial/msm_smd_tty.c @@ -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); |