From patchwork Fri Sep 18 23:31:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darren Hart X-Patchwork-Id: 7221211 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 801549F695 for ; Fri, 18 Sep 2015 23:31:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C23DC20953 for ; Fri, 18 Sep 2015 23:31:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D959B20993 for ; Fri, 18 Sep 2015 23:31:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752217AbbIRXbv (ORCPT ); Fri, 18 Sep 2015 19:31:51 -0400 Received: from mga01.intel.com ([192.55.52.88]:55340 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751811AbbIRXbv (ORCPT ); Fri, 18 Sep 2015 19:31:51 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 18 Sep 2015 16:31:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,555,1437462000"; d="scan'208";a="772209926" Received: from hanagara-mobl.amr.corp.intel.com (HELO localhost) ([10.254.56.175]) by orsmga001.jf.intel.com with ESMTP; 18 Sep 2015 16:31:49 -0700 From: Darren Hart To: Linux Kernel Mailing List Cc: Richard Purdie , Jiri Kosina , linux-input@vger.kernel.org, stable@vger.kernel.org, Darren Hart Subject: [PATCH] hid-core: Avoid uninitialized buffer access Date: Fri, 18 Sep 2015 16:31:33 -0700 Message-Id: X-Mailer: git-send-email 2.1.4 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Richard Purdie hid_connect adds various strings to the buffer but they're all conditional. You can find circumstances where nothing would be written to it but the kernel will still print the supposedly empty buffer with printk. This leads to corruption on the console/in the logs. Ensure buf is initialized to an empty string. Signed-off-by: Richard Purdie [dvhart: Initialize string to "" rather than assign buf[0] = NULL;] Cc: Jiri Kosina Cc: linux-input@vger.kernel.org Cc: stable@vger.kernel.org Signed-off-by: Darren Hart --- drivers/hid/hid-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 70a11ac..c0fbf4e 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1611,7 +1611,7 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) "Multi-Axis Controller" }; const char *type, *bus; - char buf[64]; + char buf[64] = ""; unsigned int i; int len; int ret;