From patchwork Mon Sep 12 08:43:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9325947 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 000AD6089F for ; Mon, 12 Sep 2016 08:44:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4E2228B8A for ; Mon, 12 Sep 2016 08:44:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D94DB28B90; Mon, 12 Sep 2016 08:44:54 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6492628B8D for ; Mon, 12 Sep 2016 08:44:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756837AbcILIob (ORCPT ); Mon, 12 Sep 2016 04:44:31 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:59374 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754932AbcILIo3 (ORCPT ); Mon, 12 Sep 2016 04:44:29 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue103) with ESMTPA (Nemesis) id 0LorgB-1b7q673Atv-00glwD; Mon, 12 Sep 2016 10:44:08 +0200 From: Arnd Bergmann To: Hans Verkuil Cc: Arnd Bergmann , Mauro Carvalho Chehab , Greg Kroah-Hartman , Johan Fjeldtvedt , Wei Yongjun , linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] [media] pulse8-cec: avoid uninitialized data use Date: Mon, 12 Sep 2016 10:43:49 +0200 Message-Id: <20160912084403.3577996-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:Rru8xBYaaxXgMvbr1gIUdioP46uOrk372b4xebodnpTSJp6o+SM yzFXgzny72yePLqjUMapqPHiLleUDdcXIggvNZqXax3sKdEiQ9apT9smhafCnOrkU1vtgxK JavqGXljHJIaEM0m6E92ZsQM6oJaeYqEo0QA1wbRmB/nwfz8PEUJxZaHFGAMx+WQ1tK7cNe s2uXDMMnGeCTlIjEte5JQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:Et4aIIIVLUw=:QSdEz4s8cIs/JCIeOCz9Sq aXGwhC3HWpeo9xwo+CuyHGG3Ig5afwjZkF3e2XiGiJN/IIi4QA+0WJTDzEOzIRKYv4BItiR7R 6iVV2SMdGDhbemGqEbWaW40SYGub77XAqRyLXxkawHePZ9kbisxlBxkvvenarUodmaq/E0WKk ZZf8WRd3hUkyI8j4QeHiXUzpnyAVb+6oAbqhhSx0bFFrQE+yJTZ0lm9AstfTOrBCgXER1COtj nCugRsnTNe8MlAGcqNWvwhN0T7rRGsvv6rnjtmV7as/7JsU7xOKoxWNeMK4N7wSTJ0T/i3QZN 7cFLzvH6ZanE7TTJzvYOuky2gDBL4fCuGMDSyBMJRvd5htFRS6Vu+h5+6ZTPpYXPMQPt75yyi ZmhsUtG8cwmrR4EmGuC89t+WQfXFLiyxnlu8mB/1b8hK4fwsPJtP4f6eyNgcUlwA3+kuiWu9l ry7g/R+0bcNMjj4ZwFKcA4nLwOEnxDG+7vv//XOUcyoN18+unUJlsh58QiVX3HxV3244Dm6Il yD5XjtTr1b/Myi/VTpF+cNblZ2FzJo5CFI75HUZMe574tF8RNhwu0CLixfoWPZMa/AsSUxVgt JpwaHGtptC/it9n+0YcoubWjFjcRAehdCBtmyInj6UcgyplWdhg3PtkcrV3KaghzQkKRjFp1o hf3I9u06M2x6bHzuTdg1Z7RN3Gnx7JAdI9ULbaBPQTk71ESUYE5BToPFgH7Jq7r45eeM= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Building with -Wmaybe-uninitialized reveals the use on an uninitialized variable containing the physical address of the device whenever firmware before version 2 is used: drivers/staging/media/pulse8-cec/pulse8-cec.c: In function 'pulse8_connect': drivers/staging/media/pulse8-cec/pulse8-cec.c:447:2: error: 'pa' may be used uninitialized in this function [-Werror=maybe-uninitialized] This sets the address to CEC_PHYS_ADDR_INVALID in this case, so we don't try to write back the uninitialized data to the device. Signed-off-by: Arnd Bergmann Fixes: e28a6c8b3fcc ("[media] pulse8-cec: sync configuration with adapter") --- drivers/staging/media/pulse8-cec/pulse8-cec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/pulse8-cec/pulse8-cec.c b/drivers/staging/media/pulse8-cec/pulse8-cec.c index 1158ba9f828f..64fffc709416 100644 --- a/drivers/staging/media/pulse8-cec/pulse8-cec.c +++ b/drivers/staging/media/pulse8-cec/pulse8-cec.c @@ -342,8 +342,10 @@ static int pulse8_setup(struct pulse8 *pulse8, struct serio *serio, return err; pulse8->vers = (data[0] << 8) | data[1]; dev_info(pulse8->dev, "Firmware version %04x\n", pulse8->vers); - if (pulse8->vers < 2) + if (pulse8->vers < 2) { + *pa = CEC_PHYS_ADDR_INVALID; return 0; + } cmd[0] = MSGCODE_GET_BUILDDATE; err = pulse8_send_and_wait(pulse8, cmd, 1, cmd[0], 4);