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: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
25080652a2
commit
0a083eddae
@@ -256,6 +256,13 @@ const char *tty_name(const struct tty_struct *tty)
|
||||
|
||||
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,
|
||||
const char *routine)
|
||||
{
|
||||
|
Reference in New Issue
Block a user