Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp773024img; Mon, 18 Mar 2019 14:00:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxUtrT9zwFdmJrp9myhJEfCY6G+VGoqjempKqrs1lqrNNA/Eo+dZGdmjDqIokxyRH2mMBD1 X-Received: by 2002:aa7:9313:: with SMTP id 19mr20912781pfj.173.1552942806256; Mon, 18 Mar 2019 14:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552942806; cv=none; d=google.com; s=arc-20160816; b=FW58Gm1T17o7STNfvmDQ2SaprQnnX2AC886ZgUDEPm/xm3VhvgV6W5B61BG+P5EEu2 8pk42plPIIw6Bf0IHxHdG0ZR5CwYVK73AGXOE0pNPxBRzpzV3V5qgPumRjyNpbq4/cTJ mHGXpAeAcqJa9xgf1U81/ZIO21p2/0MjtioMvTl2+rhPlyDgT14Bi1jnGEAPawQEM2PC Iff5NyyopItY5lxWH8YG6NHBGuJg4782xthizrbZzvrsc8N3vmxjeyZY1Dpn/0GmVWG7 /kMX1uzLo+P3tRAAXjALf5QGyncmx56eM4mjRRI3VF8rYShItTlGvvLDHVFX6dbFlhE9 j0gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=foD5K3yw36X4yChdThDd70OxzMyyRXtN0K3nEbI/iv0=; b=LHqeww+dDHpIyP1deGlhE2xa37m4QGjW3bspOUft4HFtOGGkgdbX/+F/3bo7aG/U3e mOP6vYqEl6LWuJIS2yHmwukY7ueaPXTqGe9qjIFNjsAA+LJ5+7X3Di9CsyhlnfXgoLd6 1iinUCfKENjTVeETvozE1Pe/I1tSt8zp1Rb+PfY7hct9RpSNhGKE5HizILYz/A3J/so1 OqNujRO/WynAYzxD4T0E5dqlaD/7WxC4WG75htmJxKmLbP60DNrhMC+tv33LnopCFE52 lJ0UM4sLAz+rwd6GXT/4ZUtrUawRd8OiZZ/QoA7lRbFcBUb4o7MPpmH4Io/21/HCwQmq 1vJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w14si9974352plq.262.2019.03.18.13.59.49; Mon, 18 Mar 2019 14:00:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727758AbfCRU6m (ORCPT + 99 others); Mon, 18 Mar 2019 16:58:42 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:37104 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726944AbfCRU6m (ORCPT ); Mon, 18 Mar 2019 16:58:42 -0400 X-UUID: c5318549fbdd484099700d7b3d543ff9-20190319 X-UUID: c5318549fbdd484099700d7b3d543ff9-20190319 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1711926507; Tue, 19 Mar 2019 04:58:36 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n2.mediatek.inc (172.21.101.79) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 19 Mar 2019 04:58:33 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 19 Mar 2019 04:58:33 +0800 From: To: , CC: , , , Sean Wang Subject: [PATCH v2] Bluetooth: btmtksdio: fix uninitialized symbol errors in btmtksdio_rx_packet Date: Tue, 19 Mar 2019 04:58:33 +0800 Message-ID: <741bf172b7d0b77e664e7edeab1bd798c955cc5b.1552942432.git.sean.wang@mediatek.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-TM-SNTS-SMTP: 0F17E529B19880F66F5DD48C42861FFE95E7862658AB986D9949304E5BF6F5182000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Wang Fixed all the below warnings. They would probably cause the following error handling path would use the uninitialized value and then produce unexpected behavior. drivers/bluetooth/btmtksdio.c:470:2: warning: ‘old_len’ may be used uninitialized in this function [-Wmaybe-uninitialized] print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ old_data, old_len, true); ~~~~~~~~~~~~~~~~~~~~~~~~ drivers/bluetooth/btmtksdio.c:376:15: note: ‘old_len’ was declared here unsigned int old_len; ^~~~~~~ drivers/bluetooth/btmtksdio.c:470:2: warning: ‘old_data’ may be used uninitialized in this function [-Wmaybe-uninitialized] print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ old_data, old_len, true); ~~~~~~~~~~~~~~~~~~~~~~~~ drivers/bluetooth/btmtksdio.c:375:17: note: ‘old_data’ was declared here unsigned char *old_data; ^~~~~~~~ v2: Remove old_len and old_data because the error path for sdio_readsb also seems wrong. And change the prefix from "mediatek" to "btmtksdio". Fixes: d74eef2834b5 ("Bluetooth: mediatek: add support for MediaTek MT7663S and MT7668S SDIO devices") Reported-by: Dan Carpenter Reported-by: Marcel Holtmann Signed-off-by: Sean Wang --- drivers/bluetooth/btmtksdio.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c index befe43f9a34a..7d0d1cb93b0e 100644 --- a/drivers/bluetooth/btmtksdio.c +++ b/drivers/bluetooth/btmtksdio.c @@ -372,8 +372,6 @@ static int btmtksdio_rx_packet(struct btmtksdio_dev *bdev, u16 rx_size) const struct h4_recv_pkt *pkts = mtk_recv_pkts; int pkts_count = ARRAY_SIZE(mtk_recv_pkts); struct mtkbtsdio_hdr *sdio_hdr; - unsigned char *old_data; - unsigned int old_len; int err, i, pad_size; struct sk_buff *skb; u16 dlen; @@ -392,12 +390,6 @@ static int btmtksdio_rx_packet(struct btmtksdio_dev *bdev, u16 rx_size) if (err < 0) goto err_kfree_skb; - /* Keep old data for dump the content in case of some error is - * caught in the following packet parsing. - */ - old_data = skb->data; - old_len = skb->len; - bdev->hdev->stat.byte_rx += rx_size; sdio_hdr = (void *)skb->data; @@ -467,8 +459,6 @@ static int btmtksdio_rx_packet(struct btmtksdio_dev *bdev, u16 rx_size) return 0; err_kfree_skb: - print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1, - old_data, old_len, true); kfree_skb(skb); return err; -- 2.18.0