Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1852932pxj; Sat, 22 May 2021 03:56:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhbm0IYx/OL0yr6HH1pMec0K6ZYr3gmKgtmZtd4lXQoCNKUFwZhhMaJfcQHniIaSdodLyg X-Received: by 2002:a17:907:77c7:: with SMTP id kz7mr14914818ejc.54.1621680965284; Sat, 22 May 2021 03:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621680965; cv=none; d=google.com; s=arc-20160816; b=feQFjbQdhV3pca1Q+VhijlRUbRbsK3w187Gp8THU4SfhBwJP6JtTPyjY8gUJ5I7yrk qeK+eeEbWmp9g5W6Mv4/Y6sEv1ExpqIKfJ1l+lUOGw+Ee1bNDNW0ugeb8aFhOQXad444 qJ36jdDTtBh+qL6E8y3M/5xklKuuDLqQk9kgBmmnB6oj81S2/tlLKWwkSx9osMwSHyrx dA0muV9XLOSZqYiCxvGDtHkBABbLis4V8aMyRHu8+42nQqRYy3Eb6FdOmbr9wsl+D5xJ prU3zLmf6UdBRv9COwWlqzsxUym7wxLz6iKf0yuX65sI79b5CWjx+T6CRj4hzSfmZTei ATPw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/pEXks9yjhGFoo2x9+/RdRi7M066Dj/Ppa8zO47Mb4E=; b=SJ/DBhTuW+anMbp6AIVE/vqxyV4NSFk2Gy7CGmhwy/H15vvNTMugCBUgufzWUXmb+c cmWWpUeut9aZ8FJXtFB2iB3vzqRPl5jHSs9Ig7iFnzS++jeBXPfFHWbLqdRUxP4JzN4v 2XLGCG1cRrPsrwTGubSGkmyyC3KTgcyFB31FrtFMaDNpqtvq4IUIQfIzpQrLsFRClpq3 jIDBAH6COx6TTfphgWgwnLJF7d6EktiojAkLlcy80XPXgLbPOjYdglk28E+fQWGOMVsP yK042R+BJMXITAiyGqEwDNy2/YoGDE7FQR/XyVN9V6YAGCT7pFtYmrHMZ3OQZDxhGgIX mPsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hd11si7547988ejc.83.2021.05.22.03.55.42; Sat, 22 May 2021 03:56:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230472AbhEVKzY (ORCPT + 99 others); Sat, 22 May 2021 06:55:24 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5740 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230236AbhEVKzU (ORCPT ); Sat, 22 May 2021 06:55:20 -0400 Received: from dggems703-chm.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FnKxn682HzqV7g; Sat, 22 May 2021 18:50:21 +0800 (CST) Received: from dggpeml500017.china.huawei.com (7.185.36.243) by dggems703-chm.china.huawei.com (10.3.19.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Sat, 22 May 2021 18:53:54 +0800 Received: from huawei.com (10.175.103.91) by dggpeml500017.china.huawei.com (7.185.36.243) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Sat, 22 May 2021 18:53:54 +0800 From: Yang Yingliang To: , , CC: Subject: [PATCH -next 2/2] ath10k: add missing error return code in ath10k_pci_probe() Date: Sat, 22 May 2021 18:58:22 +0800 Message-ID: <20210522105822.1091848-3-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210522105822.1091848-1-yangyingliang@huawei.com> References: <20210522105822.1091848-1-yangyingliang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500017.china.huawei.com (7.185.36.243) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org When chip_id is not supported, the resources will be freed on path err_unsupported, these resources will also be freed when calling ath10k_pci_remove(), it will cause double free, so return -ENODEV when it doesn't support the device with wrong chip_id. Fixes: c0c378f9907c ("ath10k: remove target soc ps code") Fixes: 7505f7c3ec1d ("ath10k: create a chip revision whitelist") Fixes: f8914a14623a ("ath10k: restore QCA9880-AR1A (v1) detection") Reported-by: Hulk Robot Signed-off-by: Yang Yingliang --- drivers/net/wireless/ath/ath10k/pci.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index 463cf3f8f8a5..71878ab35b93 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -3685,8 +3685,10 @@ static int ath10k_pci_probe(struct pci_dev *pdev, ath10k_pci_soc_read32(ar, SOC_CHIP_ID_ADDRESS); if (bus_params.chip_id != 0xffffffff) { if (!ath10k_pci_chip_is_supported(pdev->device, - bus_params.chip_id)) + bus_params.chip_id)) { + ret = -ENODEV; goto err_unsupported; + } } } @@ -3697,11 +3699,15 @@ static int ath10k_pci_probe(struct pci_dev *pdev, } bus_params.chip_id = ath10k_pci_soc_read32(ar, SOC_CHIP_ID_ADDRESS); - if (bus_params.chip_id == 0xffffffff) + if (bus_params.chip_id == 0xffffffff) { + ret = -ENODEV; goto err_unsupported; + } - if (!ath10k_pci_chip_is_supported(pdev->device, bus_params.chip_id)) + if (!ath10k_pci_chip_is_supported(pdev->device, bus_params.chip_id)) { + ret = -ENODEV; goto err_unsupported; + } ret = ath10k_core_register(ar, &bus_params); if (ret) { -- 2.25.1