Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp775439rwb; Wed, 26 Jul 2023 02:40:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlF44FLnSUaGT8lzADSvCcpmcIe5TgxVnjY9ZNTHXHDt2le04pu4h+OhwbeQM7DP05DxCLjJ X-Received: by 2002:a05:6a00:24d2:b0:680:252d:da3e with SMTP id d18-20020a056a0024d200b00680252dda3emr1691038pfv.5.1690364414230; Wed, 26 Jul 2023 02:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690364414; cv=none; d=google.com; s=arc-20160816; b=T/nW76Po/cNwYmITw3L/mwCwUmU09SoMIURVskNmAbuRyr3SZHyz47GtwWU0WkZ5hB EuO5Y73BHYQsahIc027mspf9x8bkpBCcY+wxZNTtMtekWnl7L3eWwdcMORahNreXZTT8 rOejSHSm/ZqK8fGsiq/jYL5rcXz1WczHYmRJeYkZtVx8iWQRoi+3mehI74JxA/ymoSxR I9lT7AiviB+kPNWbd2ue93CJu/DPw/TS3sjmJWLFaf1h0JqMfAWM/DTx3IwK5mG+7zjr nYJcYZfZYHKOMThkBxBWLb7GSfddtDjQa5nT1AMO6ViLtMbtFXAVUIzYgRWko7wc+mpf 7Cjg== 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:cc:to:from:dkim-signature; bh=oWz8EwbBIUuxVy7ApB8AxGYWCSmyH8C6z9DQBLklzCg=; fh=239N9TPK33Qn7ha+Q0sQ3fNhJmIROSC7xWfxOgJDZ+k=; b=h0vH3BEfCnR7X52wEEUdjaJx0COYV8PLn5PH8lR3N8zPsgTLCJHHReodjX3CigwnN/ jJdc9hIgFEy+98IChUNdbU5CkP2w/3ui9wMuttaIlhccak36xVmPeEZ72bBXrYeyIwxP hUNm9gaetcL4jE89nKpkTYlDS/enW5nuaq355js9TDNvQ7bcRRtzLoUYDSb9rZGgSy6p I6ukCRZ9yPHjKiY0MSmEnE/Zf8eDdX0kMuMBPq8qKx/SsUMoYodiPsAuTiXbMiSnPX0I 1IWnU3M3Q/xgSuX3JbvguM7YzVUi4zPVvFBF2/PQ+hvyh3oVaMyxA9+JEhPFeK40ZoYx HH/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="Vo4ioW/E"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p17-20020a056a000b5100b0067e69fcebb9si12746273pfo.86.2023.07.26.02.40.05; Wed, 26 Jul 2023 02:40:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=@quicinc.com header.s=qcppdkim1 header.b="Vo4ioW/E"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232613AbjGZJ3H (ORCPT + 58 others); Wed, 26 Jul 2023 05:29:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232682AbjGZJ2h (ORCPT ); Wed, 26 Jul 2023 05:28:37 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F37CC4237 for ; Wed, 26 Jul 2023 02:26:47 -0700 (PDT) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36Q6bMXw008458; Wed, 26 Jul 2023 09:26:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=oWz8EwbBIUuxVy7ApB8AxGYWCSmyH8C6z9DQBLklzCg=; b=Vo4ioW/E/dVaOL8pEbL1zGd7XW5SNZxRNwRRedWTnAahmDVd0zSgJWAVN8Mom4g8NlVF chnAWwwD4jvpk9PaIlf3nnG5yfyGdeqRm6HmwWd6ag+UAvFFghEeQ+pIX06jIzcoy4v6 aRn5wa7xLuBVZWDRPMJlDj5nA6k84TYMkMvm7l9pYJc5IDJ2H1XDVLp4/2O2fC2crm0o wx57abA8MlmoxoXFYdSawbZWLWCozXHlDocnzWnlemXe+v+vKNkct2UurJr73OMJG0iT sURXZsVu+L/Fnl2aAD8StrR4VtmDAGUt623LI1LxOuOd/IUViGtXQIN/IpkIL3aSU1hZ sA== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s2v4tghba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jul 2023 09:26:41 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36Q9Qeqc013506 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jul 2023 09:26:40 GMT Received: from wgong-HP3-Z230-SFF-Workstation.qca.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Wed, 26 Jul 2023 02:26:39 -0700 From: Wen Gong To: CC: , Subject: [PATCH] ath12k: Fix a NULL pointer dereference in ath12k_mac_op_hw_scan() Date: Wed, 26 Jul 2023 05:26:25 -0400 Message-ID: <20230726092625.3350-1-quic_wgong@quicinc.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 5ka9MlkJEtvpgHSGoRPbCNMwTUHC0c-4 X-Proofpoint-GUID: 5ka9MlkJEtvpgHSGoRPbCNMwTUHC0c-4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-26_03,2023-07-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 mlxscore=0 bulkscore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 mlxlogscore=783 malwarescore=0 adultscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307260083 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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-wireless@vger.kernel.org In ath12k_mac_op_hw_scan(), the return value of kzalloc() is directly used in memcpy(), which may lead to a NULL pointer dereference on failure of kzalloc(). Fix this bug by adding a check of arg.extraie.ptr. Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4 Signed-off-by: Wen Gong --- drivers/net/wireless/ath/ath12k/mac.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index 1bb9802ef569..af46b63bb15b 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -2755,9 +2755,12 @@ static int ath12k_mac_op_hw_scan(struct ieee80211_hw *hw, arg.scan_id = ATH12K_SCAN_ID; if (req->ie_len) { + arg.extraie.ptr = kmemdup(req->ie, req->ie_len, GFP_KERNEL); + if (!arg.extraie.ptr) { + ret = -ENOMEM; + goto exit; + } arg.extraie.len = req->ie_len; - arg.extraie.ptr = kzalloc(req->ie_len, GFP_KERNEL); - memcpy(arg.extraie.ptr, req->ie, req->ie_len); } if (req->n_ssids) { base-commit: b21fe5be53eb873c02e7479372726c8aeed171e3 -- 2.40.1