Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp192063ybv; Wed, 19 Feb 2020 19:18:02 -0800 (PST) X-Google-Smtp-Source: APXvYqxUneIPfkLMo0BUbXO/6GHAMYtn3IVHFPOP6YeseV+LQf4c40NxdJfdswuqIDoicmhFOQA4 X-Received: by 2002:a05:6830:606:: with SMTP id w6mr22571437oti.323.1582168681885; Wed, 19 Feb 2020 19:18:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582168681; cv=none; d=google.com; s=arc-20160816; b=oHDbeoOeg+ujJ8hAHtXzwboz3V1tyQqfnV/7/V9pv/fjY0nW9/Vw/B9LoFlWBj4T2v zQvw6DlnHOJH+0dQ9a2qdz+Z98EFr1nLryqQBLxgKVQwe8KOrq1te0pr2Si8sva0Dpii HYPcMnCudhISkxAgTmz5etj4+GHEu1jXjx67cwBuPQ4oEUKUqO1nR0BNPMwG1iiIri3p RdN7Kzy6jMZ+02d3SlUC8Nin6XoLiCdzjIZCo5rSNwLNdIa3QAdrLX9wnEFmrRSsobaR BoRhJzSUCVWcu8yhLunZAVXhi3kD1KX1op+3sGwiSBZzsmhL3wYxrjmTsxcRK3zs2rR4 K8dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=i2O9M22wRHGvAOZAL5G1kwDrP71Yc5DXVKcI6ikT/o0=; b=VqvplyUtLtPXq61T5ySH0NXMT6cY8kq3U7UmidApdyEue65uWv30LALbE2sDXI/b6p dpwHnRHTjRzugyj1ApQN1+5J/GesMMQ4MTAIhr/xal59JJQRRToAaeREP6+hiV090/KP DQ5byOXrIRyaf0s1iZizjNwUD0ZULUtP2c5UWVcp5FmRKTy3QHA8GXbmLqs58aqKSqOy ZDc4ObWZ1MsRMlJN674lfWlycIMCcgUuU3747dknz8J55UMQKgoRXQMH0btuvZQZyA/z PcKOQgpt5/AYEpe9yCwDoE98IGVjOsZN9xa/UebsBbCBd6+NSev7H84mT3PVl/nmxiK/ CuWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dlpnFhTJ; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h203si10881126oif.3.2020.02.19.19.17.50; Wed, 19 Feb 2020 19:18:01 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=dlpnFhTJ; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727950AbgBTDRl (ORCPT + 99 others); Wed, 19 Feb 2020 22:17:41 -0500 Received: from mail-pg1-f202.google.com ([209.85.215.202]:34854 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727476AbgBTDRl (ORCPT ); Wed, 19 Feb 2020 22:17:41 -0500 Received: by mail-pg1-f202.google.com with SMTP id j29so1425347pgj.2 for ; Wed, 19 Feb 2020 19:17:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=i2O9M22wRHGvAOZAL5G1kwDrP71Yc5DXVKcI6ikT/o0=; b=dlpnFhTJuppuR+7jhHOrc29QhJDsFb/a9lebelLf5+HpvXJAn1SQBioq39Qk8Vm3AQ CaUiiTHkAgza79JX7dXl3SCPyyIwwCB2Zj6DbBTVEGF8c5wauY6xKMi8xxVKZw//JS2H 3jDmVyKsKRudtiC4BeHrWuJZBL7iFYElm8LYKpLUaScuxhcalPyXP634Spg/cogqQq8j 35xfj0nCeAwlfsWLTdbma6cb6Xzb82XaO/bSzayA2HwEPYyOQefA3WQvS7F/X8tFzwn+ PZl1jwhrpg0riUoXF0V61wIeJb0iKteX2/MQYwSMrRU6X8BqMrFqbojtUyrLd10crM2Z 1fdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=i2O9M22wRHGvAOZAL5G1kwDrP71Yc5DXVKcI6ikT/o0=; b=jPSk6g5yI6J6iahJ6EqiYaU7kzxKaP9p+EC3Xq2emzLLKrBUJ2wzeWi/KUQnEoJ2ei Mj4OIOdmNrFLIssa7TorLAA5twFOk7fOesWAGEERPWKC9UNmk4xaPXSDE6mDcrml4CkI f74T/DkfiEvuix9nk2ErYNej8BPwKzh+7y5MuDAbo2v8++8dCTedxVwpypUxI7r1p70j fET8EZbhPdFXivsbY4fISNzOLQlH2EalC6C8Jxupw/IXcy+du5YG9nVqLpTOUiGoAl9I IsTZWtgJ9el6xnYMkKHsh/R76hqr/B+/3/XFiYsv1SkVX3vkHmtoH+dTyqLh35N+P4mj 9RQg== X-Gm-Message-State: APjAAAXXECR4ZhYCml/02sfj9hBkWH2s1f69B/UadsU0FRk+VWxn4tdV vZlipF048URHpOH0bxUCY/KSpjOHwfcldqbhQg== X-Received: by 2002:a63:b250:: with SMTP id t16mr29658302pgo.18.1582168660404; Wed, 19 Feb 2020 19:17:40 -0800 (PST) Date: Thu, 20 Feb 2020 11:17:29 +0800 Message-Id: <20200220111711.Bluez.v3.1.I145f6c5bbf2437a6f6afc28d3db2b876c034c2d8@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog Subject: [Bluez PATCH v3] bluetooth: fix passkey uninitialized when used From: Howard Chung To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Howard Chung , kbuild test robot , "David S. Miller" , Johan Hedberg , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski , clang-built-linux@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch fix the issue: warning:variable 'passkey' is uninitialized when used here Link: https://groups.google.com/forum/#!topic/clang-built-linux/kyRKCjRsGoU Reported-by: kbuild test robot Suggested-by: Marcel Holtmann Signed-off-by: Howard Chung --- Changes in v3: - rephrase the commit message Changes in v2: - refactor code net/bluetooth/smp.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 50e0ac692ec4..929e0bebaf80 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -2115,7 +2115,7 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb) struct l2cap_chan *chan = conn->smp; struct smp_chan *smp = chan->data; struct hci_conn *hcon = conn->hcon; - u8 *pkax, *pkbx, *na, *nb; + u8 *pkax, *pkbx, *na, *nb, confirm_hint; u32 passkey; int err; @@ -2179,13 +2179,12 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb) */ if (hci_find_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, hcon->role)) { - err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, - hcon->type, - hcon->dst_type, - passkey, 1); - if (err) - return SMP_UNSPECIFIED; - set_bit(SMP_FLAG_WAIT_USER, &smp->flags); + /* Set passkey to 0. The value can be any number since + * it'll be ignored anyway. + */ + passkey = 0; + confirm_hint = 1; + goto confirm; } } @@ -2206,9 +2205,11 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb) err = smp_g2(smp->tfm_cmac, pkax, pkbx, na, nb, &passkey); if (err) return SMP_UNSPECIFIED; + confirm_hint = 0; +confirm: err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, hcon->type, - hcon->dst_type, passkey, 0); + hcon->dst_type, passkey, confirm_hint); if (err) return SMP_UNSPECIFIED; -- 2.25.0.265.gbab2e86ba0-goog