Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp288968lqm; Tue, 30 Apr 2024 23:38:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW+N2pOrRcMksK0rMGHP2Rheb1buzOoE16VP1B2Vwm0KzJi2RzRwpNbRelxEn4H6HoPiOAEiRrBcY3rpg0MjSbXOG4eqakH41Iw6GvQ0A== X-Google-Smtp-Source: AGHT+IEB/6vB7CHSdDMD8bBS8Ck9jCWs3/XlTLG6hlRxe+5cPofHIw10okrj0YjSBP3fAqgnFHPZ X-Received: by 2002:ae9:c10d:0:b0:790:f930:e1ca with SMTP id z13-20020ae9c10d000000b00790f930e1camr1442833qki.26.1714545518738; Tue, 30 Apr 2024 23:38:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714545518; cv=pass; d=google.com; s=arc-20160816; b=WQ0fNfPoCCKTIxYpXuJcHBme336j1IV5ZYxhvOtP8iNDsZaL8Qw5tATCTcqV3Anzmn gAQdnNOkDnF0ZKGm70jpgYJfNz18eMA1jxSQ942TcsSpxmJO1QtW4DjvnqlJ/NOFmMzg QbriO8PbLDEv/P1qFJxog8qFuf8sJGjvfAufE/0HwDVj0PI1KwK5uppSuywEp/ZPLMiY KphKJT42xYJmwAcCHEFyTSDH5dHy7j0mUJ1pJNqxL0hciRBYx5G7dQcJ7V0sMM0mrYFC zqXIg3SiuBh6Fl30IKzhWjOJ6q6KGZxnfy9ABjgAxIGZ4tytIiEaSydakOfi0H1es7tm isEA== ARC-Message-Signature: i=2; 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=b81gQ3RV71CaIdGw/U5XqUThKltBGudSVCgcMWiTDSM=; fh=5l9NW27V6ksth/xTYfZHRIczyczc0JLjq/BxjTu2dSo=; b=ie6j7szYO6RVKCPQlTcfUxEiCGxxERFgdKWMtQATThe+s5YmhJeOoAT9J3U0CC6Pru IvNdWiA7t1KZre0XnjJZcxyXxIZVdM4jyDBSTUlEkA2qx/xGhffpAeCL9pYAChqHIZ/1 V/M+eCEcNxq1sCsZ/uXpWAvhg+rb2A65NWmK3pwIYBoC/FznzDXOVDZFnxvrp6kcKD+d gagnjBgAICea2AC9HnAWnHL7q+7gpOkn6HQpOJUGxzoRwMzsLanIbY4MaUYD0X/1I9h/ hRaS3Basd1ZhVkDMItRJL975kNP9YY+azbnQ+/OO5ot9lojDIjvZVkbYPoRZ/Xn19PX5 LWaw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tINNV4jH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-bluetooth+bounces-4214-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4214-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w12-20020a05620a0e8c00b0078ef7fa9e96si30235136qkm.650.2024.04.30.23.38.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 23:38:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4214-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tINNV4jH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-bluetooth+bounces-4214-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4214-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 76A0F1C218BA for ; Wed, 1 May 2024 06:38:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C23A937169; Wed, 1 May 2024 06:38:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tINNV4jH" 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 1ABF97F; Wed, 1 May 2024 06:38:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714545509; cv=none; b=G3SxsJnwaimFrkxyChK2zvf7ujVuanWDv5Vn8AysFsQGJJ43OwqdXTs5ialLOlolYO+FzQN0VvcPjtFEBdswCSmvd7a2ld9C0+s41D3HJcKJaOsKhtPzzGWRuo5hrwsCgn/MoRESZmdYQA01epc3X688dWe03xKy4V3cI4cVyeI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714545509; c=relaxed/simple; bh=GgOMexD4ak2pHmlX701c4dP3+z5taFdQAY8Z5LSFuVE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=OXkU4abWEmrmYio3F6IDnKebN/hCqmtTg5Zia5WihBF09v/RLWbp+RFh8Qblkyjh4qK0tOmWRoVEam8JI48ENBIqT3Zofrn/zxIr+ty2pSJ0cQE5hchg33TknLMCDsgK3083yxkSog+G+bfbJfDWw0A8kx/Rz3GP+QOkhHwfhNo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tINNV4jH; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94F10C113CC; Wed, 1 May 2024 06:38:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714545508; bh=GgOMexD4ak2pHmlX701c4dP3+z5taFdQAY8Z5LSFuVE=; h=From:To:Cc:Subject:Date:From; b=tINNV4jHz9NQ3DFyT32nHJ4RoB2Lo5Jm9HG0hOY19cca7iA13OaeewMUbpKx5/u7E GkT7rnxqtcqqRmVKfef9NG+S8cu1llKbBDTKcc+2EEpZd78r+dYj7ArlFMPip6fzWB /8i+vr7BV8prQGAJYZIQIhovr+DYX8k79n7tI1wpJcKcwXpvM9gswr8xOEQ0J4SjVN MMpd+bbht1wJ3saAeyuv3E2VFj3rVMnclYAFNWFRbI1YXdCvEZDVW8j+EYkwvcHqNd Pr213hfCPNPYXKcF5nkbMhcETK1MW1KMbL1uPrxlYvEYLAG8OZ4zbLSKg7GRb9viS3 fb8bLIYjKhhpw== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1s23bp-000000008Ly-3o1R; Wed, 01 May 2024 08:38:30 +0200 From: Johan Hovold To: Marcel Holtmann , Luiz Augusto von Dentz Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH] Bluetooth: qca: fix firmware check error path Date: Wed, 1 May 2024 08:37:40 +0200 Message-ID: <20240501063740.32066-1-johan+linaro@kernel.org> X-Mailer: git-send-email 2.43.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 A recent commit fixed the code that parses the firmware files before downloading them to the controller but introduced a memory leak in case the sanity checks ever fail. Make sure to free the firmware buffer before returning on errors. Fixes: 6fb81c405bfa ("Bluetooth: qca: add missing firmware sanity checks") Cc: stable@vger.kernel.org # 4.19 Signed-off-by: Johan Hovold --- drivers/bluetooth/btqca.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Luiz, Sorry for not catching this before posting v2. Feel to free to squash this fix into commit 6fb81c405bfa ("Bluetooth: qca: add missing firmware sanity checks") in the bluetooth-next branch if you prefer. Note that the commit id in the Fixes tag above won't match if you cherry pick both commits to the fixes branch. Johan diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c index 125f140e012a..59e384fa1a0c 100644 --- a/drivers/bluetooth/btqca.c +++ b/drivers/bluetooth/btqca.c @@ -676,7 +676,7 @@ static int qca_download_firmware(struct hci_dev *hdev, ret = qca_tlv_check_data(hdev, config, data, size, soc_type); if (ret) - return ret; + goto out; segment = data; remain = size; -- 2.43.2