Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5490160iog; Wed, 22 Jun 2022 22:07:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ude5MCVtuMvzcpRiKS69pNjp1EjC/h1jp3AMF/uffqNtPSIz37t6Jl05S9uY4TVUXEPbXF X-Received: by 2002:a17:907:7e8b:b0:711:e5e6:6694 with SMTP id qb11-20020a1709077e8b00b00711e5e66694mr6423301ejc.35.1655960850114; Wed, 22 Jun 2022 22:07:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655960850; cv=none; d=google.com; s=arc-20160816; b=yoA3oBTHv23EseC8yOtcru5XXN1faN5tYXZT0Mao24cV04cZlpTLKPWbd5bnHZXesn 9wO6m8VdxN6YFNJ5ewSTCWAH/qmae+uIISwJH5OU1Zc5K+H2xnVFzEJe/u/Z6aRU2H82 T6z1D3x8iF5j/6HN3ZZaskZafyK7g60eRFtm/kFwYJra4yErJogi1q7qVyqJCMleSJFP 8twUFcTvzSxqFcXg+V3yL7Ch0avKZb7mDOZbPkbEvAkitAocmXCiSrbzFiBCu8RfwaWh qoXMWjDiTdeWXYZJ05bAqSt+IBDsz6Bk7i50KFlcen90rnZugqmS1+sN6zOfytbSLs9+ Y4Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=/9qFyabmBcibChahYmaud4vPnIfjnmUdYUKhUTjcTys=; b=fRKDBQHtlUX3MIhqjujfWxhB8HGLdfIeJToJDW5mvF7Zn9U4ETDCYUAh5FrQk/eHnN M1+lAMf/IprqqOl2UNtQixAIOt4WzRwC++lxOrCnYOqpJ0sLVntjz7+r0jTtrPGfo45A K9Q9pxLuPGeZAT6NPRDVR2eN2DjdLHT447kFIDwRPq42FleuyjCBIs8SpGJwgHFoVmUS bHjNAOMtFDrZ1lrlbZZz2gpXZ0/YtxJjR55xeXgAQNrpMdSXmbDolsfXcctgUUJSveGb Fn3ZFrXfV2lEvaf9eFiscd7+uaeExmIX/oxSUyIkH5hN+1POIobvtcBJCIRSxwCYUx8d 2/Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=B4iQFshu; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp20-20020a170906c15400b00722e80fff4dsi6310107ejc.66.2022.06.22.22.06.40; Wed, 22 Jun 2022 22:07:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=B4iQFshu; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbiFWFBA (ORCPT + 99 others); Thu, 23 Jun 2022 01:01:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbiFWFAd (ORCPT ); Thu, 23 Jun 2022 01:00:33 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19435496B9 for ; Wed, 22 Jun 2022 21:45:22 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id s185so12295696pgs.3 for ; Wed, 22 Jun 2022 21:45:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=/9qFyabmBcibChahYmaud4vPnIfjnmUdYUKhUTjcTys=; b=B4iQFshue5+ocH1qvrbcRq/LTKcTziF7ORkG1R/P+gI1Vo0E43UAVQymwggvHC7ghN 0jwy5eSOaQUCfNM09AQQ2xjFIZ+Snh2f8XWS3VRSV3rE35QXt83ag5Vzvs/6CHcFwqv6 HoY1oP71HaWZCYRYl/vm1hZcowC5MBSCkrQGOYZO46CPMksKO2Lynbs9yCKcoGXLXPX7 9mIBUFGqYIdrswy5z0fWnvEfxL2pR6ZzsXBcQ4qObjOBpBoHDA1fZAG6qbb3zW4lgM7L XqMxTpxJgqREhNH8mAOvaw6aGsXXqHVYYJc1ojq3/ocBquHmuXtscKCzNEyp8QZBqvLO Is8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=/9qFyabmBcibChahYmaud4vPnIfjnmUdYUKhUTjcTys=; b=VHIajiyO2zjELAsZWo9hAWqH6ZnDCmU7NVBr0K/onBKEDzbA6U2HNdpTyFgUU98XW6 J7byS2xTJg8BFp3EkCN+HvedUuq2aXiZqyLmn7tOe0pik2SNOtO2A2neXsMlMLWroji+ VdL4QLwU8Scoqtt1Hiovt2wX2kxpN+j9Guig/RrNS4Z8odWIrqZqH/YjiiPdldokIlgL TxBAyrtApg5+0++6GXmWPU0O69ayhneZrXXsJdePPadwrSGc4NkYhEINFdTViOGGqo4g WSYGtZAXUW0ZJRgnvbU91p/aaPqKRJ5eIii+tvei35rqeRs8wYWAwdp7Wm87MbAXp+cF ORLA== X-Gm-Message-State: AJIora8m6ykDjP0Ck/QeSlMgevBN9gGYf+dY8edHpMAa1hmaINuVMyrl MYtSPcA3TYE36WcyY+eqZpDTXzPrVzI= X-Received: by 2002:a63:8c47:0:b0:40d:2d4:e3a2 with SMTP id q7-20020a638c47000000b0040d02d4e3a2mr6183819pgn.2.1655959521355; Wed, 22 Jun 2022 21:45:21 -0700 (PDT) Received: from han1-NUC8i7BEH.hsd1.or.comcast.net ([2601:1c0:6a01:d830:29c0:aef5:a13f:9fde]) by smtp.gmail.com with ESMTPSA id b3-20020a170902e94300b00168adae4eb2sm13646213pll.262.2022.06.22.21.45.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 21:45:21 -0700 (PDT) From: Tedd Ho-Jeong An To: linux-bluetooth@vger.kernel.org Subject: [BlueZ PATCH] mgmt-tester: Fix null dereference issue reported by scan-build Date: Wed, 22 Jun 2022 21:45:20 -0700 Message-Id: <20220623044520.458626-1-hj.tedd.an@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Tedd Ho-Jeong An This patch fixes the null dereference reported by the scan-build. tools/mgmt-tester.c:12025:28: warning: Access to field 'cap_len' results in a dereference of a null pointer (loaded from variable 'rp') [core.NullDereference] if (sizeof(rp->cap_len) + rp->cap_len != length) { ^~~~~~~~~~~ --- tools/mgmt-tester.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c index f45a6c015..6018327f1 100644 --- a/tools/mgmt-tester.c +++ b/tools/mgmt-tester.c @@ -12020,12 +12020,14 @@ static void read_50_controller_cap_complete(uint8_t status, uint16_t length, tester_warn("Failed to read advertising features: %s (0x%02x)", mgmt_errstr(status), status); tester_test_failed(); + return; } if (sizeof(rp->cap_len) + rp->cap_len != length) { tester_warn("Controller capabilities malformed, size %zu != %u", sizeof(rp->cap_len) + rp->cap_len, length); tester_test_failed(); + return; } while (offset < rp->cap_len) { -- 2.34.1