Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1046279pxp; Thu, 17 Mar 2022 01:21:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydA57Ga3c4zOPIlcY9zkUEVY0yR6EVaNtXDlGeiG8DR064+yFOfpe6dX1aveorHAm5pj4K X-Received: by 2002:a17:906:3ac7:b0:6ce:c3a1:3dcf with SMTP id z7-20020a1709063ac700b006cec3a13dcfmr3216474ejd.182.1647505316136; Thu, 17 Mar 2022 01:21:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1647505316; cv=pass; d=google.com; s=arc-20160816; b=VIwi6JUNdB1RxJ+MPmD3rsJuPGvogvVK6fcMk3ZE3YKWaxi0407Q67mf7rL7AUSeAS v+eQKYk71UzMDgBNyYa6wUi4ev0DX+LG6EC1iSaZ9kvk5tTenPsZbJY/4wrmzGX7ONSm qPYSsEw8WhcQRH3LJ4h1u4lYDupq/heZSAy44/NeMGjk9zv98dmjqIR+TRDshz7ePBNi WlSxDCiOGEVss3HN5almawlTcoqCb5cM2KUyQWtR8QpdkOUU9dT9QGCK0BSNmgSrcT3O QjQyilXMwYVrjLYjiE6ZvXnuTf1TQv/fDPEq3S/JTsJbd80uaUsQyQ/gdVuk7476dRTU 4cWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:content-disposition :message-id:subject:cc:to:from:date:dkim-signature:dkim-signature; bh=1wwtIo7L4DG0PWLtiJTR0HgseMBOpdqqEQyAdqDJtX8=; b=UgAYj9XNbmztfXQI5L63jdyjMjy9ZNhI+kAFxw1R4S0MmRl77dcKRi3CnMZk96Ns0j I0ndvdOfP4RjuzBPJ8MvZ0scO2YSf8J04aLjslaJsxhhuvec9YxXk3k8NWyvLVsgLcp7 /kUO58BLI9bpRMluswuRqTFY+Du6AtzFaAcAWLIKAEN3Y1szh06uje9qlU6hn9UfAZQ+ AKs9j2jXNDecaZkfcbXFxNCuuzuhPS11s5rJJXm7MMrauRaXw5DnMyKbgU2c7i45jmNu sveLRzyb5oJQZEQoyutUlIyhvrq3+mziVJV6wVjS5mSdEGSZm7IvLfbNkTNUukAWFH92 TPSQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2021-07-09 header.b=WSRfJ1NH; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=c7hrHfDl; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); 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=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a50e404000000b00418c2b5bf90si1053016edm.626.2022.03.17.01.21.16; Thu, 17 Mar 2022 01:21:56 -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=@oracle.com header.s=corp-2021-07-09 header.b=WSRfJ1NH; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=c7hrHfDl; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); 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=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229577AbiCQH7U (ORCPT + 99 others); Thu, 17 Mar 2022 03:59:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbiCQH7T (ORCPT ); Thu, 17 Mar 2022 03:59:19 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 702B7D1CDC; Thu, 17 Mar 2022 00:58:03 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22H3DwrL030863; Thu, 17 Mar 2022 07:57:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : content-type : mime-version; s=corp-2021-07-09; bh=1wwtIo7L4DG0PWLtiJTR0HgseMBOpdqqEQyAdqDJtX8=; b=WSRfJ1NH8qIoUtJyrEJWh+e0TcldjHboysdyTskkBEThOi8rnwMQdB43tznjX6ltEx1K 98PYRTIoJv8QCH7WzEY7hikWe31poovPFIg4tZ4Y4nNUrF4NSi9kEtUNEc10HgyibHdq SE5JOorpQytwmOdi+dS3PAL7U+kH8pMVggaDhwN7SnXTJhHzbG4d5zkzAeXN0ZQRBNcu 2Z98dWLJQIXZWYThejptGku48Uox2vlGe9YeNglgaaDAYzBARf9WdPraOwljRuVP7IIV DoP5p218cdyaYFEo9JdxudPlMfNXxLKwAGmw8K7f0U2/kGlM0t+sRoLGnB9pto4mwREI aw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3et5s6rgny-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Mar 2022 07:57:54 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22H7uhIY087524; Thu, 17 Mar 2022 07:57:53 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by aserp3020.oracle.com with ESMTP id 3et64m5f2a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Mar 2022 07:57:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y/nMmLIqwRMHh5jRW/I9fgbOmYVFjgx/IvmDrnW9TRle2wn38M4YCZlrSIgNw2u86nl6X+wLPegYHMYZpw796VAccU0+qyKmg8AOz6+jFd+2gHYpBQjAqzLSe+Xsu0PhykZgkBOe/ncJczY8c6q6mWHU75H/BvMGea/ymzz0uOgekjBflgoByM7L0RIUZur92/BxI11rWx4HkFfMfr11X5B5LhOeTKJuSQ6bvlXtdFgpLiqzmVwyduSiEKuwl7/TibOJ/LTwfmCshLacW02aOnqIVc3qlqeMi/usGxBaxFtzuV+W7yZ6xRxXBsOwlc69SSRm+or9kSJb5KDHfclfdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1wwtIo7L4DG0PWLtiJTR0HgseMBOpdqqEQyAdqDJtX8=; b=klLVjD3DkcHdPpF+8JuAYogufcR1gb4ilMO/bcFDT29vq6J9AZNWAaFxofS9+AmLFvAqHLxV2V7e7F+27BYRl7P6Fwwzndg6jTsVK4mrz3Ho4X1/sbENRA1OToEeTzSKH7ht+xRsdj78zZ2frRnvdhODJyOGE0R9FFHR1z2OX1xDo9nJm5rJIkzHyyGL8vRzGIsgXhbo/7RqeO7yT2uMm4bX5ntQ0iERh0sRYg7wga63Bj5hr8bYvvkRYBxTRtSyyHaPmPSeNQvjyBvvPbpSx3JCitPIL1gncq5Z7n5LimBFzFf8yHEcHSjjplud67OwSsuzgR+2GUEXhVuVXOfBDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1wwtIo7L4DG0PWLtiJTR0HgseMBOpdqqEQyAdqDJtX8=; b=c7hrHfDlXO4wUayq9d0S1UMMISPNGmPk9Z3wmlxRwcv+YRF9FXv/+OMHQhf63VBt+5vCuTKJLyKJaGfgfOSRhiYQEvSYSJW+E/yRg3Lph5SqJsVeaFtMUDIMqGEW0JdARUv2Oyk5o/sgIbTTjSLxbhpyNfTvJVykYrBIZSotg9A= Received: from MWHPR1001MB2365.namprd10.prod.outlook.com (2603:10b6:301:2d::28) by DS7PR10MB5390.namprd10.prod.outlook.com (2603:10b6:5:3a1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.15; Thu, 17 Mar 2022 07:57:51 +0000 Received: from MWHPR1001MB2365.namprd10.prod.outlook.com ([fe80::2c3d:92b5:42b3:c1c5]) by MWHPR1001MB2365.namprd10.prod.outlook.com ([fe80::2c3d:92b5:42b3:c1c5%4]) with mapi id 15.20.5081.017; Thu, 17 Mar 2022 07:57:51 +0000 Date: Thu, 17 Mar 2022 10:57:40 +0300 From: Dan Carpenter To: Sean Wang Cc: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , Matthias Brugger , linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, kernel-janitors@vger.kernel.org Subject: [PATCH] Bluetooth: btmtkuart: fix error handling in mtk_hci_wmt_sync() Message-ID: <20220317075740.GE25237@kili> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.10.1 (2018-07-13) X-ClientProxiedBy: ZR0P278CA0098.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:23::13) To MWHPR1001MB2365.namprd10.prod.outlook.com (2603:10b6:301:2d::28) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b6a5e1ad-8742-442c-d286-08da07ebd5cb X-MS-TrafficTypeDiagnostic: DS7PR10MB5390:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZoAitzrVf/ijL/31Ga+X1Z7Fc1/0GxH1Fak4xn5P3uRdOdWarHth086Ck6lvZWN0/bgy+unx28/z7Utqb86fGVQJRf5h/68ur3c9YVlT8rwd8zchvnin9eJhESyQvZyNXGfzxgO7Np7nPhxTWglTrHuEkLwjwsksehcTVPvPJXsQlf4ewhmLoyKnGazNarA/2QSYZ/V2VJBJAB/cNu5aZPDCqiYEVCbNSeKGWPwYThMWj0lixEL+k+YrahkinC6ijE+6ZYIFNDbEMfcJVRfOM3kW4ZaRpqnz+qBBA10SogdKDv2+yxq8m5yaaNeieIJ1A089NauHPRtEVQThHA3+4kp2wrbebgSvH4PpM47ojQr+Usk+59tcZnTBeBYWq8CfIM+AHwWNbPKXBuR5FNAYCEZlz2SiV4etovEN73Xzpx2SiMDTS8y1N3TVBNoRxTGawIX1Qes/77MJ4huiAATxZWA6dDRkcJW5MpL98SQ+Xh+cviLX2iCfGdIi+ieXMe0YJtWPy3TroUcMteivMQdfbf13+5uHRx4R8RpOkYv8t5ATN/Rf3ZfEjZOSkM98rkuPALdKv9fYg4kAhEejvjOA1+6NaMGA9Lz8mfRavu8LzOsECxcEt8ox4ofp3ed355ZfJHU4E5mY8RAWfax3CmEnMHOcIXxqfb86y2l4N1hCT7RgVSdgXS4c3E06yOg2PQX8m/+xeTFK2sOJd0L0CnBnTw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2365.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(7916004)(366004)(5660300002)(83380400001)(33716001)(44832011)(2906002)(316002)(54906003)(6916009)(4326008)(8676002)(66476007)(66556008)(508600001)(66946007)(9686003)(186003)(6512007)(86362001)(6486002)(6666004)(38100700002)(38350700002)(6506007)(52116002)(33656002)(1076003)(26005)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?dH5gk+YJZc6KaRTocW7qXyoa6uSTWmbBwxtCsybt8JqhlrJVhZz+aXLt4I3J?= =?us-ascii?Q?a5ygl0NIjKtFNdbAIZTPAp54r2pjj3PhhhHZuXxqXhz5EUggqidqS+PQpIae?= =?us-ascii?Q?nxCXXUWkC86JV7ROqv77vLAAe/zY9tOZbhh2rOSr6yRNej7hmLYIys8TlVlJ?= =?us-ascii?Q?hSQYSp01Ha7COXVrS8kU9FZYGWYXxnkM/zXgTcl/SSxlrYEK7P5zD1JGOyDg?= =?us-ascii?Q?XaIaaV/V3Lg8h52d8QU3kultCnojQYk1kN0l8z2oV/8ngqvYUHV0PmvkEM5E?= =?us-ascii?Q?PeqSc3yNb2DV3Bs2IJi/NyG5sf1t7pQ2zMFN4BPO+htrZzkAK+jymadh6ICj?= =?us-ascii?Q?49BDI+aE7+BgdTDsmWuqoU5+UEO4run2GjBarefBsXJG+Nsm45zarMHkAUT9?= =?us-ascii?Q?hMM1rG6RH3MosFRKtXcZIcbeuv5xYWPeWucduW56kGb2YU23rpElPUuHWUJu?= =?us-ascii?Q?h7YICoX7vxW26FdqzBSGTAGM77jwTZRhJ4BkW+xjZakUuNw9XySd6MQAQTf/?= =?us-ascii?Q?YJU+RhQIwzjrrB+OAC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6hFpI3et4a?= =?us-ascii?Q?5lRv3FaSe5levq9LjezbqKFKffXfqTidtjmEzc2aoukLsAhu/qw/4Q=3D=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6a5e1ad-8742-442c-d286-08da07ebd5cb X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2365.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2022 07:57:51.3053 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Djw8bGDmMwnmWWH7Nv00g2ciLhhfaZgdXhXI+X3bqsSySyJ1SJkbiznDoDsyrXB4gjYjxTGF/MvKHmatlcTIh57KuHjGDhDQcAgs78jvLso= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5390 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10288 signatures=693715 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 malwarescore=0 mlxscore=0 suspectscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203170046 X-Proofpoint-GUID: cm8RZROjrhZRLfLAS3R4E4rYWPSVjjZu X-Proofpoint-ORIG-GUID: cm8RZROjrhZRLfLAS3R4E4rYWPSVjjZu X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, 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 This code has an uninitialized variable warning: drivers/bluetooth/btmtkuart.c:184 mtk_hci_wmt_sync() error: uninitialized symbol 'wc'. But it also has error paths which have memory leaks. Fixes: 8f550f55b155 ("Bluetooth: btmtkuart: rely on BT_MTK module") Signed-off-by: Dan Carpenter --- drivers/bluetooth/btmtkuart.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/bluetooth/btmtkuart.c b/drivers/bluetooth/btmtkuart.c index 695e1225b08c..c98691cdbbd5 100644 --- a/drivers/bluetooth/btmtkuart.c +++ b/drivers/bluetooth/btmtkuart.c @@ -105,8 +105,10 @@ static int mtk_hci_wmt_sync(struct hci_dev *hdev, } wc = kzalloc(hlen, GFP_KERNEL); - if (!wc) - return -ENOMEM; + if (!wc) { + err = -ENOMEM; + goto err_free_skb; + } hdr = &wc->hdr; hdr->dir = 1; @@ -153,7 +155,7 @@ static int mtk_hci_wmt_sync(struct hci_dev *hdev, bt_dev_err(hdev, "Wrong op received %d expected %d", wmt_evt->whdr.op, hdr->op); err = -EIO; - goto err_free_skb; + goto err_free_wc; } switch (wmt_evt->whdr.op) { @@ -177,11 +179,11 @@ static int mtk_hci_wmt_sync(struct hci_dev *hdev, if (wmt_params->status) *wmt_params->status = status; +err_free_wc: + kfree(wc); err_free_skb: kfree_skb(bdev->evt_skb); bdev->evt_skb = NULL; -err_free_wc: - kfree(wc); return err; } -- 2.20.1