From patchwork Tue Jan 7 20:54:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 234397 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AACB9C33C9B for ; Tue, 7 Jan 2020 21:02:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7E2BF20880 for ; Tue, 7 Jan 2020 21:02:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578430949; bh=Pf+OGz+1yK/rXxvQjEg7VSpjfIaC0mFgSTEUWmZv348=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=wekTz6rp/yJNm42smEjroLI9Kn3xJS8tjMcXt/cPqb0EEMX7gSvwpITuLtnBhMC6v vJ7yOqrC6ApmZ9SgkHQtbU94f6ugAFoKFoMQkwn+qBvm0IadrVlkzOQaZBzNModkdA 6B6CbfEg4B84rkDMEE5asVAB/YT8QsogM6cYierI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727536AbgAGVC2 (ORCPT ); Tue, 7 Jan 2020 16:02:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:42052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727234AbgAGVC0 (ORCPT ); Tue, 7 Jan 2020 16:02:26 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CC94C222D9; Tue, 7 Jan 2020 21:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578430945; bh=Pf+OGz+1yK/rXxvQjEg7VSpjfIaC0mFgSTEUWmZv348=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q5gttiroUJM9KD/2JNtZFhaY9o+k5o3pjdHKTY9h3mDBpIdpy7YLm7Ylx6XCr+9P1 6iSJCZ2lL4UU/Gtb0TlLL3zJ8Tjno7nIdrPBojxZOKU9PqdbiSaWV/lJzA5IkqSYRF hgqT5iL24nKtHfFbWoucR9SkS+lLvTK6yob6xz2o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Navid Emamdoost , Marcel Holtmann Subject: [PATCH 5.4 160/191] Bluetooth: Fix memory leak in hci_connect_le_scan Date: Tue, 7 Jan 2020 21:54:40 +0100 Message-Id: <20200107205341.538631171@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200107205332.984228665@linuxfoundation.org> References: <20200107205332.984228665@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Navid Emamdoost commit d088337c38a5cd8f0230fbf2d514ff7672f9d0d3 upstream. In the implementation of hci_connect_le_scan() when conn is added via hci_conn_add(), if hci_explicit_conn_params_set() fails the allocated memory for conn is leaked. Use hci_conn_del() to release it. Fixes: f75113a26008 ("Bluetooth: add hci_connect_le_scan") Signed-off-by: Navid Emamdoost Signed-off-by: Marcel Holtmann Signed-off-by: Greg Kroah-Hartman --- net/bluetooth/hci_conn.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1176,8 +1176,10 @@ struct hci_conn *hci_connect_le_scan(str if (!conn) return ERR_PTR(-ENOMEM); - if (hci_explicit_conn_params_set(hdev, dst, dst_type) < 0) + if (hci_explicit_conn_params_set(hdev, dst, dst_type) < 0) { + hci_conn_del(conn); return ERR_PTR(-EBUSY); + } conn->state = BT_CONNECT; set_bit(HCI_CONN_SCANNING, &conn->flags);