Received: by 2002:a05:7412:e79e:b0:f3:1519:9f41 with SMTP id o30csp229435rdd; Wed, 22 Nov 2023 14:18:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEueuDl4HjWuuDkJoTvgf0HJvWaUF42Ob/M0AzpXZtaAZ03uPc+Z73PNzifFo5OYGDT0X93 X-Received: by 2002:a17:90b:1d09:b0:280:1695:7b5 with SMTP id on9-20020a17090b1d0900b00280169507b5mr4006063pjb.12.1700691498285; Wed, 22 Nov 2023 14:18:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700691498; cv=none; d=google.com; s=arc-20160816; b=DrKkfQtfZYvw4MW4wJ+uRAQVzd5wvsRthBNQcWjp5q07a/NXpkEeS+AFFmSB9MFgLB 7ES9tsj7Z29IG2NjD6x7GQG8NfD4JANbkVPtzUKZyR6bALi2tDHSg7nleByT4BttpLFB HuvOcFqC2qGI0u7var/DLVCH6u+n9PZSRFTFytwg8XU3UFH0PC95Nj12DlqFP5qPXdsd KjG2BWLXn7d5InXOD1Ne8/o3G+tSj+UPG9UhohQ5Rl9WG96CAsjISQo3z4Cl6/4BHNGS pnPCwGjqhBR/g/5SRXOyG7o6KMYN4IvFm4cKXiXCs09qmRt/ff8mXnNKYory55oS/s9+ 7pWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=zFVC2DfV3fHTK+xXPFsYauB+rdJ1FQ2NmXgZhnp50lE=; fh=1fWl7cVe6LDjzG/CpL4UgOOjKuk+SXAnhBIwUsB6oxA=; b=FqqB21zSF/s/zD1MEtEjwd8W/BBk6qzsU5DObDo+oWWbAoiQr4Ub5QAUMyN6YfMLcy oWi97UH3w+rxhaqqLZfBQ3Mxt1ti9yc3r6afmM6Bg+MUNhjH02L1pvwlj9Cchjqt5d59 94BXggTd3t/kLSlKsCMXbgMtH4u+UtE/M2x4YatxuRDE9xXSr6C3dX+k3JMnSHySReBd 3SRoxIHzVSbMjh7BRsnI7txAhZuo/1rkn9XuJFBO9yaCKduKxLrY8PJ/tALoq76SYIeP UIEgOsvt7HN+3Jr65CrE/NIexZRoQpbh7wDW40mG2eUVdxBnulkR0PzV55IG12oobNOF 1IWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=glKHthNQ; spf=pass (google.com: domain of linux-bluetooth+bounces-181-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-181-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p23-20020a17090a931700b0027901ee93fbsi484307pjo.156.2023.11.22.14.18.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 14:18:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-181-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=glKHthNQ; spf=pass (google.com: domain of linux-bluetooth+bounces-181-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-181-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 725F728143B for ; Wed, 22 Nov 2023 22:18:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8389D1F616; Wed, 22 Nov 2023 22:18:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="glKHthNQ" X-Original-To: linux-bluetooth@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C569519BDE for ; Wed, 22 Nov 2023 22:18:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89133C433C7; Wed, 22 Nov 2023 22:18:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700691492; bh=pXFt8KxeskxjDuI8ULnmxTHFdpsi5bDQYyGvBUP0idU=; h=From:To:Cc:Subject:Date:From; b=glKHthNQb4E6cjtC2SuFlrOYnN7It85p9TOtJ0JMC6aWadKlgzcoRO06Dmw/whaTC NbwX1bwg/a0Uim3ArNlImVetSYLA4oxmr7C5q+rmkWxGtdntO99QZfFdqiH2f78VeE dlNw3RHFZB2gNP/Ap1/dz5HFByoKjRdqhhXO9y5/vtI2DZtqFnvdbbhFxu+CAoGjpB 1StCDTO9rSvyrhd2NgieezOF5gCXCQwnd2CtDUxzx+NGI6TQsOWPcC+UzUWYJ8HqYW am9ZpkKIN4LimfObGivje5pIysb5yeR7pgqfqcQppqIC1fxo4hYGwEbK5Aq3LfE2TU 5u5dqCrUP4JkQ== From: Arnd Bergmann To: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , "Gustavo A. R. Silva" Cc: Arnd Bergmann , Iulia Tanasescu , Pauli Virtanen , Jakub Kicinski , "Lee, Chun-Yi" , Claudia Draghicescu , Ziyang Xuan , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Bluetooth: hci_event: shut up a false-positive warning Date: Wed, 22 Nov 2023 23:17:44 +0100 Message-Id: <20231122221805.3139482-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann Turning on -Wstringop-overflow globally exposed a misleading compiler warning in bluetooth: net/bluetooth/hci_event.c: In function 'hci_cc_read_class_of_dev': net/bluetooth/hci_event.c:524:9: error: 'memcpy' writing 3 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=] 524 | memcpy(hdev->dev_class, rp->dev_class, 3); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The problem here is the check for hdev being NULL in bt_dev_dbg() that leads the compiler to conclude that hdev->dev_class might be an invalid pointer access. Add another explicit check for the same condition to make sure gcc sees this cannot happen. Fixes: a9de9248064b ("[Bluetooth] Switch from OGF+OCF to using only opcodes") Fixes: 1b56c90018f0 ("Makefile: Enable -Wstringop-overflow globally") Signed-off-by: Arnd Bergmann --- net/bluetooth/hci_event.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 5b6fd625fc09..5651e96e78da 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -516,6 +516,9 @@ static u8 hci_cc_read_class_of_dev(struct hci_dev *hdev, void *data, { struct hci_rp_read_class_of_dev *rp = data; + if (WARN_ON(!hdev)) + return -ENXIO; + bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); if (rp->status) -- 2.39.2