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

Commit 0a083edd authored by Peter Hurley's avatar Peter Hurley Committed by Greg Kroah-Hartman
Browse files

tty: core: Add helper fn to deref tty driver name



Similar to tty_name(), add tty_driver_name() helper to safely
dereference tty->driver->name (otherwise return empty string).

Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 25080652
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -256,6 +256,13 @@ const char *tty_name(const struct tty_struct *tty)


EXPORT_SYMBOL(tty_name);
EXPORT_SYMBOL(tty_name);


const char *tty_driver_name(const struct tty_struct *tty)
{
	if (!tty || !tty->driver)
		return "";
	return tty->driver->name;
}

static int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
static int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
			      const char *routine)
			      const char *routine)
{
{
+1 −0
Original line number Original line Diff line number Diff line
@@ -420,6 +420,7 @@ static inline struct tty_struct *tty_kref_get(struct tty_struct *tty)
}
}


extern const char *tty_name(const struct tty_struct *tty);
extern const char *tty_name(const struct tty_struct *tty);
extern const char *tty_driver_name(const struct tty_struct *tty);
extern void tty_wait_until_sent(struct tty_struct *tty, long timeout);
extern void tty_wait_until_sent(struct tty_struct *tty, long timeout);
extern int __tty_check_change(struct tty_struct *tty, int sig);
extern int __tty_check_change(struct tty_struct *tty, int sig);
extern int tty_check_change(struct tty_struct *tty);
extern int tty_check_change(struct tty_struct *tty);