Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp598209img; Mon, 18 Mar 2019 09:58:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMzfC9oCVRKCB9b+XFabSOryOZM7mfDAuYdYwZwZenuncVxqAoXscZ1ERGTqQA9DxC41aH X-Received: by 2002:a65:5184:: with SMTP id h4mr18591626pgq.32.1552928280951; Mon, 18 Mar 2019 09:58:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552928280; cv=none; d=google.com; s=arc-20160816; b=Y8FU4t2p4gNNOR/RjCKy15pUuPY1QFzUVXY3E+edVcMgm2fQcPoSz5vXR4h60p2E88 XGhyObNEWHE8OmEfhODE9DCBt7Bak7nlX7hWy0Bf/xhBhnnbbNRkeVRrSzucEATEqLV+ euCIBKKuVtXe4LgEpluJXcsM+sTxHPfe2QNsWRmLS6Zxmviewm9i+wFxGshIwxNrCnsr 8uCpB+6ggsqq5B+FB5fn7LlEMuwl8trPiH93uBMmyDCfwxLBHIS0Bq7Tt5HRrWSmioKT r83L5h12d0/GMR6lItF1TozDU/mKrVqb216OeMsm88ehIyOweDJ7qP3YZf5PHoLDcZcg GqBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=uak6sdqd/6zDgJ/7fquyA31t/a5PqG/drUA9RK/dXOQ=; b=zUVwnNC+RZr0bemm95GOFOmcOg2s5CDdFbZvd8iQZlVw1mV4uyYGxvZHX68VVv9uE6 Gx4PQ2vQ9gzEnOY79J5XpT8SGfbx1nc+CJWMEeNAVEhHF9RF2iMwPlYoFhziwWo5UcZA m7vpwqVExzRode9B9Bg0vOFRImGjyi+7Lck41C50eBR9FEeZtP6Hg1cV7BNVeYNLP+S0 hmiVDENpwKOqsJ0Nhjs8X6fPRta3om/9QT2YpGb/uCArlAkioVIaGgOdKSfNK5kGwAxx 9CP9LDCZZ6xwM+cJ1pwwn/CoPvGGgBe4f830Np5N/Ze2C8DzGkt1RI0+Rx5HoR6x9JPN sgNQ== 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 w6si9006011pgp.129.2019.03.18.09.57.45; Mon, 18 Mar 2019 09:58:00 -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 S1727537AbfCRQzj convert rfc822-to-8bit (ORCPT + 99 others); Mon, 18 Mar 2019 12:55:39 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:42603 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726765AbfCRQzj (ORCPT ); Mon, 18 Mar 2019 12:55:39 -0400 Received: from marcel-macpro.fritz.box (p4FEFC449.dip0.t-ipconnect.de [79.239.196.73]) by mail.holtmann.org (Postfix) with ESMTPSA id D9450CF172; Mon, 18 Mar 2019 18:03:37 +0100 (CET) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: [PATCH] Bluetooth: mediatek: fix uninitialized symbol errors in btmtksdio_rx_packet From: Marcel Holtmann In-Reply-To: <8fb8e6840a39127112597963d665fbe6c21d8b91.1552509647.git.sean.wang@mediatek.com> Date: Mon, 18 Mar 2019 17:55:37 +0100 Cc: Johan Hedberg , linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <93CB6259-6FB8-4D3D-9FF3-8EB59499A6A1@holtmann.org> References: <8fb8e6840a39127112597963d665fbe6c21d8b91.1552509647.git.sean.wang@mediatek.com> To: Sean Wang X-Mailer: Apple Mail (2.3445.102.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sean, > 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; > ^~~~~~~~ > > 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 | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c > index b4b8320f279e..23cf63888bac 100644 > --- a/drivers/bluetooth/btmtksdio.c > +++ b/drivers/bluetooth/btmtksdio.c > @@ -372,8 +372,8 @@ 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; > + unsigned char *old_data = NULL; > + unsigned int old_len = 0; > int err, i, pad_size; > struct sk_buff *skb; > u16 dlen; or instead just remove this whole old_len + old_data stuff anyway since it is rather pointless. Or at least introduce a proper error path for sdio_readsb since you know when it fails, there is no point in writing the SKB. Regards Marcel