Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751893AbbKHSCh (ORCPT ); Sun, 8 Nov 2015 13:02:37 -0500 Received: from mail-ig0-f169.google.com ([209.85.213.169]:33267 "EHLO mail-ig0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751063AbbKHSBk (ORCPT ); Sun, 8 Nov 2015 13:01:40 -0500 From: Peter Hurley To: Greg Kroah-Hartman Cc: Jiri Slaby , linux-kernel@vger.kernel.org, Peter Hurley Subject: [PATCH 05/14] tty: core: Add helper fn to deref tty driver name Date: Sun, 8 Nov 2015 13:01:12 -0500 Message-Id: <1447005681-4912-6-git-send-email-peter@hurleysoftware.com> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1447005681-4912-1-git-send-email-peter@hurleysoftware.com> References: <1447005681-4912-1-git-send-email-peter@hurleysoftware.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1578 Lines: 47 Similar to tty_name(), add tty_driver_name() helper to safely dereference tty->driver->name (otherwise return empty string). Signed-off-by: Peter Hurley --- drivers/tty/tty_io.c | 7 +++++++ include/linux/tty.h | 1 + 2 files changed, 8 insertions(+) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index f463894..7a7b77d 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -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) { diff --git a/include/linux/tty.h b/include/linux/tty.h index 0532465..a9c1af9 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -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_driver_name(const struct tty_struct *tty); 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); -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/