]> Git Repo - linux.git/commitdiff
tty: make tty_ldisc_ops a param in tty_unregister_ldisc
authorJiri Slaby <[email protected]>
Wed, 5 May 2021 09:19:09 +0000 (11:19 +0200)
committerGreg Kroah-Hartman <[email protected]>
Thu, 13 May 2021 14:57:16 +0000 (16:57 +0200)
Make tty_unregister_ldisc symmetric to tty_register_ldisc by accepting
struct tty_ldisc_ops as a parameter instead of ldisc number. This avoids
checking of the ldisc number bounds in tty_unregister_ldisc.

Signed-off-by: Jiri Slaby <[email protected]>
Cc: William Hubbs <[email protected]>
Cc: Chris Brannon <[email protected]>
Cc: Kirk Reiser <[email protected]>
Cc: Samuel Thibault <[email protected]>
Cc: Marcel Holtmann <[email protected]>
Cc: Johan Hedberg <[email protected]>
Cc: Luiz Augusto von Dentz <[email protected]>
Cc: Dmitry Torokhov <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Wolfgang Grandegger <[email protected]>
Cc: Marc Kleine-Budde <[email protected]>
Cc: Andreas Koensgen <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Rodolfo Giometti <[email protected]>
Cc: Peter Ujfalusi <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Jaroslav Kysela <[email protected]>
Cc: Takashi Iwai <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
19 files changed:
drivers/accessibility/speakup/spk_ttyio.c
drivers/bluetooth/hci_ldisc.c
drivers/input/serio/serport.c
drivers/misc/ti-st/st_core.c
drivers/net/caif/caif_serial.c
drivers/net/can/slcan.c
drivers/net/hamradio/6pack.c
drivers/net/hamradio/mkiss.c
drivers/net/ppp/ppp_async.c
drivers/net/ppp/ppp_synctty.c
drivers/net/slip/slip.c
drivers/pps/clients/pps-ldisc.c
drivers/tty/n_gsm.c
drivers/tty/n_hdlc.c
drivers/tty/n_null.c
drivers/tty/tty_ldisc.c
include/linux/tty.h
net/nfc/nci/uart.c
sound/soc/ti/ams-delta.c

index 8faa27bae6bfc244686c389cca76a5986f722d7f..0b7f1a87eaeb48d326ccfa0c69260b97170f0097 100644 (file)
@@ -219,7 +219,7 @@ void spk_ttyio_register_ldisc(void)
 
 void spk_ttyio_unregister_ldisc(void)
 {
-       if (tty_unregister_ldisc(N_SPEAKUP))
+       if (tty_unregister_ldisc(&spk_ttyio_ldisc_ops))
                pr_warn("speakup: Couldn't unregister ldisc\n");
 }
 
index ee32006e8fc95741295b5cf390b8e3379a8a6918..31e0c804363c51a546d1a05048f19eddbcf90980 100644 (file)
@@ -917,7 +917,7 @@ static void __exit hci_uart_exit(void)
 #endif
 
        /* Release tty registration of line discipline */
-       err = tty_unregister_ldisc(N_HCI);
+       err = tty_unregister_ldisc(&hci_uart_ldisc);
        if (err)
                BT_ERR("Can't unregister HCI line discipline (%d)", err);
 }
index 870b1d2606fcd95ecee2dbd115b9228ccd85e952..7fbbe00e3553c921c5f65f886be91f222e45cbbd 100644 (file)
@@ -304,7 +304,7 @@ static int __init serport_init(void)
 
 static void __exit serport_exit(void)
 {
-       tty_unregister_ldisc(N_MOUSE);
+       tty_unregister_ldisc(&serport_ldisc);
 }
 
 module_init(serport_init);
index a4f5d02940c7c4af98090d7112400ff5f291715b..174ae8e52805857433e3307908667006771b81b0 100644 (file)
@@ -872,7 +872,7 @@ int st_core_init(struct st_data_s **core_data)
        st_gdata = kzalloc(sizeof(struct st_data_s), GFP_KERNEL);
        if (!st_gdata) {
                pr_err("memory allocation failed");
-               err = tty_unregister_ldisc(N_TI_WL);
+               err = tty_unregister_ldisc(&st_ldisc_ops);
                if (err)
                        pr_err("unable to un-register ldisc %ld", err);
                err = -ENOMEM;
@@ -892,7 +892,7 @@ int st_core_init(struct st_data_s **core_data)
        if (err) {
                pr_err("error during st_ll initialization(%ld)", err);
                kfree(st_gdata);
-               err = tty_unregister_ldisc(N_TI_WL);
+               err = tty_unregister_ldisc(&st_ldisc_ops);
                if (err)
                        pr_err("unable to un-register ldisc");
                return err;
@@ -919,7 +919,7 @@ void st_core_exit(struct st_data_s *st_gdata)
                kfree_skb(st_gdata->rx_skb);
                kfree_skb(st_gdata->tx_skb);
                /* TTY ldisc cleanup */
-               err = tty_unregister_ldisc(N_TI_WL);
+               err = tty_unregister_ldisc(&st_ldisc_ops);
                if (err)
                        pr_err("unable to un-register ldisc %ld", err);
                /* free the global data pointer */
index 2407a0f6656d3ab2f57bcfaf89111dba4e88727f..d0c24dba4a86d7ff95bff1ff1cd99414729c5bab 100644 (file)
@@ -447,7 +447,7 @@ static void __exit caif_ser_exit(void)
        spin_unlock(&ser_lock);
        ser_release(NULL);
        cancel_work_sync(&ser_release_work);
-       tty_unregister_ldisc(N_CAIF);
+       tty_unregister_ldisc(&caif_ldisc);
        debugfs_remove_recursive(debugfsdir);
 }
 
index e3f528c82242538525ca7a0feb733c0c09bcc831..03a2dbd3c3672567018d7bb6476ab9886a0c0688 100644 (file)
@@ -784,7 +784,7 @@ static void __exit slcan_exit(void)
        kfree(slcan_devs);
        slcan_devs = NULL;
 
-       i = tty_unregister_ldisc(N_SLCAN);
+       i = tty_unregister_ldisc(&slc_ldisc);
        if (i)
                printk(KERN_ERR "slcan: can't unregister ldisc (err %d)\n", i);
 }
index 4db1d3c4d771bbe87fd9af2e500a4bd4a9c7a252..aac24f9caceb92c2a550abbe027631b2a9037325 100644 (file)
@@ -781,7 +781,7 @@ static void __exit sixpack_exit_driver(void)
 {
        int ret;
 
-       if ((ret = tty_unregister_ldisc(N_6PACK)))
+       if ((ret = tty_unregister_ldisc(&sp_ldisc)))
                printk(msg_unregfail, ret);
 }
 
index 1eb87a5a93948aad436ba934ad0b13b9cc4aec94..750c6afc930295c09cb1bebc198fed3206deaca8 100644 (file)
@@ -967,7 +967,7 @@ static void __exit mkiss_exit_driver(void)
 {
        int ret;
 
-       if ((ret = tty_unregister_ldisc(N_AX25)))
+       if ((ret = tty_unregister_ldisc(&ax_ldisc)))
                printk(msg_unregfail, ret);
 }
 
index 4bfb66c40c86dfdd478fd7441f323965e791e3ea..b2d454d01ebaedbe82e1be360ce6fac762433e8d 100644 (file)
@@ -1016,7 +1016,7 @@ static void async_lcp_peek(struct asyncppp *ap, unsigned char *data,
 
 static void __exit ppp_async_cleanup(void)
 {
-       if (tty_unregister_ldisc(N_PPP) != 0)
+       if (tty_unregister_ldisc(&ppp_ldisc) != 0)
                printk(KERN_ERR "failed to unregister PPP line discipline\n");
 }
 
index 0942d3ee48e08c6bbeabb2272412a7dbc55798a8..ca403bde56fb8d123097f7ae556da62a546607f3 100644 (file)
@@ -727,7 +727,7 @@ err:
 static void __exit
 ppp_sync_cleanup(void)
 {
-       if (tty_unregister_ldisc(N_SYNC_PPP) != 0)
+       if (tty_unregister_ldisc(&ppp_sync_ldisc) != 0)
                printk(KERN_ERR "failed to unregister Sync PPP line discipline\n");
 }
 
index 938ac0ec030566eee2a83212ce579d9ff090e03d..867efff40a0e8936b7471b6febdbecb956cde7e8 100644 (file)
@@ -1360,7 +1360,7 @@ static void __exit slip_exit(void)
        kfree(slip_devs);
        slip_devs = NULL;
 
-       i = tty_unregister_ldisc(N_SLIP);
+       i = tty_unregister_ldisc(&sl_ldisc);
        if (i != 0)
                printk(KERN_ERR "SLIP: can't unregister line discipline (err = %d)\n", i);
 }
index 2a88e678d0b8d17201d3f5b14c16ecaf1cc3360f..91b947f37774c264bf028168d27c8437b8591b04 100644 (file)
@@ -131,7 +131,7 @@ static void __exit pps_tty_cleanup(void)
 {
        int err;
 
-       err = tty_unregister_ldisc(N_PPS);
+       err = tty_unregister_ldisc(&pps_ldisc_ops);
        if (err)
                pr_err("can't unregister PPS line discipline\n");
        else
index cce2ef04caeb89be52f35c0d84372371debaa04e..db7d4a30af91fda35e7532d2ca4b9c08aed9fd4b 100644 (file)
@@ -3280,13 +3280,13 @@ static int __init gsm_init(void)
 err_put_driver:
        put_tty_driver(gsm_tty_driver);
 err_unreg_ldisc:
-       tty_unregister_ldisc(N_GSM0710);
+       tty_unregister_ldisc(&tty_ldisc_packet);
        return status;
 }
 
 static void __exit gsm_exit(void)
 {
-       int status = tty_unregister_ldisc(N_GSM0710);
+       int status = tty_unregister_ldisc(&tty_ldisc_packet);
        if (status != 0)
                pr_err("n_gsm: can't unregister line discipline (err = %d)\n",
                                                                status);
index 2256039911f575e50721c377653140f9377befba..c2afbfe0a1d57955e84df58f6702583e6c7db77c 100644 (file)
@@ -822,8 +822,7 @@ static int __init n_hdlc_init(void)
 
 static void __exit n_hdlc_exit(void)
 {
-       /* Release tty registration of line discipline */
-       int status = tty_unregister_ldisc(N_HDLC);
+       int status = tty_unregister_ldisc(&n_hdlc_ldisc);
 
        if (status)
                pr_err("N_HDLC: can't unregister line discipline (err = %d)\n",
index ee229c812dce58f975c9465de157995c2668b2f9..f913b665af725d699b2a9d7ad8cd335905e6ecf1 100644 (file)
@@ -57,7 +57,7 @@ static int __init n_null_init(void)
 
 static void __exit n_null_exit(void)
 {
-       tty_unregister_ldisc(N_NULL);
+       tty_unregister_ldisc(&null_ldisc);
 }
 
 module_init(n_null_init);
index 9aff04bee4cdad0fe18db92bf017fcdf8fbe5c52..d02deeb5e584bc52ea6803dccc5ef72a0b6e783d 100644 (file)
@@ -87,19 +87,16 @@ EXPORT_SYMBOL(tty_register_ldisc);
  *             takes tty_ldiscs_lock to guard against ldisc races
  */
 
-int tty_unregister_ldisc(int disc)
+int tty_unregister_ldisc(struct tty_ldisc_ops *ldisc)
 {
        unsigned long flags;
        int ret = 0;
 
-       if (disc < N_TTY || disc >= NR_LDISCS)
-               return -EINVAL;
-
        raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
-       if (tty_ldiscs[disc]->refcount)
+       if (tty_ldiscs[ldisc->num]->refcount)
                ret = -EBUSY;
        else
-               tty_ldiscs[disc] = NULL;
+               tty_ldiscs[ldisc->num] = NULL;
        raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
 
        return ret;
index 95c632299fb46b1621f571363c940f28fdf869f5..6a72d0ff63910f30fbba1eb6754b9a0f169d34b2 100644 (file)
@@ -637,7 +637,7 @@ static inline int tty_port_users(struct tty_port *port)
 }
 
 extern int tty_register_ldisc(struct tty_ldisc_ops *new_ldisc);
-extern int tty_unregister_ldisc(int disc);
+extern int tty_unregister_ldisc(struct tty_ldisc_ops *ldisc);
 extern int tty_set_ldisc(struct tty_struct *tty, int disc);
 extern int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p,
                                 const char *f, int count);
index 648c26b4bad8087dfcf6565c7c2d8e680ca00166..502e7a3f8948b6564f56bf19b412fd6143f67e1c 100644 (file)
@@ -462,7 +462,7 @@ static int __init nci_uart_init(void)
 
 static void __exit nci_uart_exit(void)
 {
-       tty_unregister_ldisc(N_NCI);
+       tty_unregister_ldisc(&nci_uart_ldisc);
 }
 
 module_init(nci_uart_init);
index fcbb791bf27a518cde3fec8792ebed88eeb022ae..e89548e4836403f2a4ba9ffe32116d214c02c389 100644 (file)
@@ -583,7 +583,7 @@ static int ams_delta_remove(struct platform_device *pdev)
 {
        struct snd_soc_card *card = platform_get_drvdata(pdev);
 
-       if (tty_unregister_ldisc(N_V253) != 0)
+       if (tty_unregister_ldisc(&cx81801_ops) != 0)
                dev_warn(&pdev->dev,
                        "failed to unregister V253 line discipline\n");
 
This page took 0.10019 seconds and 4 git commands to generate.