From patchwork Mon Nov 7 23:22:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhinakaran Pandiyan X-Patchwork-Id: 9416215 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D2FA76048F for ; Mon, 7 Nov 2016 23:22:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2BFF28E38 for ; Mon, 7 Nov 2016 23:22:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B555A28E74; Mon, 7 Nov 2016 23:22:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5663028E38 for ; Mon, 7 Nov 2016 23:22:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 26C0B6E2F0; Mon, 7 Nov 2016 23:22:48 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id D02E16E2F0 for ; Mon, 7 Nov 2016 23:22:46 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP; 07 Nov 2016 15:22:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,459,1473145200"; d="scan'208";a="898814032" Received: from nuc-skylake.jf.intel.com ([10.54.75.23]) by orsmga003.jf.intel.com with ESMTP; 07 Nov 2016 15:22:46 -0800 From: Dhinakaran Pandiyan To: intel-gfx@lists.freedesktop.org Date: Mon, 7 Nov 2016 15:22:16 -0800 Message-Id: <1478560936-2581-1-git-send-email-dhinakaran.pandiyan@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <874m3j85ib.fsf@intel.com> References: <874m3j85ib.fsf@intel.com> Cc: Dhinakaran Pandiyan Subject: [Intel-gfx] [PATCH v2] drm/dp: Make space for null terminator in the DP device ID char array X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP The DP device identification string read from the DPCD registers is 6 characters long at max. and we store it in a char array of the same length without space for the NULL terminator. Fix this by increasing the array size to 7 and initialize it to an empty string. v2: Use %*pE format specifier (Jani) Signed-off-by: Dhinakaran Pandiyan --- drivers/gpu/drm/drm_dp_helper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c index 3e6fe82..2d42760 100644 --- a/drivers/gpu/drm/drm_dp_helper.c +++ b/drivers/gpu/drm/drm_dp_helper.c @@ -544,7 +544,7 @@ void drm_dp_downstream_debug(struct seq_file *m, DP_DETAILED_CAP_INFO_AVAILABLE; int clk; int bpc; - char id[6]; + char id[6] = ""; int len; uint8_t rev[2]; int type = port_cap[0] & DP_DS_PORT_TYPE_MASK; @@ -584,7 +584,8 @@ void drm_dp_downstream_debug(struct seq_file *m, } drm_dp_downstream_id(aux, id); - seq_printf(m, "\t\tID: %s\n", id); + len = strnlen(id, 6); + seq_printf(m, "\t\tID: %*pE\n", len, id); len = drm_dp_dpcd_read(aux, DP_BRANCH_HW_REV, &rev[0], 1); if (len > 0)