Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1088240lqt; Fri, 7 Jun 2024 07:44:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXnM/oY5fuVONBVSoiYGNeWTzNu2Bu8C28YrmnCfy1pzPZYId9xxGeP4vGuv5jesjPqaExtctIf6tR/L++X8elIB94V1N3eKS8rdyazrw== X-Google-Smtp-Source: AGHT+IFXCyZgmp3BcWRoaEgUhu5MIL/A5vTIqHtp5LWYvPFulOcbuw59zFdPa8Fgn0mpIE3f4Lwf X-Received: by 2002:a17:906:bcd4:b0:a68:7b9b:5176 with SMTP id a640c23a62f3a-a6cd7d68aedmr194171066b.44.1717771477091; Fri, 07 Jun 2024 07:44:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717771477; cv=pass; d=google.com; s=arc-20160816; b=xiSKxb8u8ndb6wqCaHk+uc6d6XB33tBC0pJdblTTOGktkZfYix9OUbH/I0vGxfYJry vc/X4g64nCWNiJ4pw3Awv0h/O678p6BQf0WFf3x/aw26sHXALSNd40Uf8BcemZbzrpuG f5KKVQPEy2KYd+EWP0yAXlGXjFbO3EOWilnerKaMKUrC8Ps92/v73SfA4BFz7zneVkPG k7F7sDn/jQjnBANhSNNsfGTKG5imltCHW97nMT3xcw3eyFnt7NDYmzqz/0u039rE3ATl IW5IJsZz6cRzEw1aCeSD4gz7WGS9ACne5l7pi0QcFRJPIoO/lWj/FkDrjs3vMrCw8Q5s LhKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6RI6aD1aRcRnRr23fMfwPOE6rq2EmxPFWYovc/OqDYY=; fh=ukiS6CsuQVCkzIlWTz+EYwz/nbbe0dMX7FJnxqi+qUU=; b=S+3zycFw+ctex8C9EerN4hHp3tHx76Qgb8f3pWp87SJ73W+DnmHATRePnz5C++Ig9J +IkdXsmo6DumLB3JyHQRyhQrwhbdm9xQycFdjDJlTZPs/4XX0+dYC6cIYBbsFEtFyXa3 oOcaUC+ZFXzmuf3da16B8il5ur37vFqaSHiUFdlR8C94YmqSTNi39O+POi7ty0Llgm2n asPhWOhxHWKzPppw+CUNzR2Kr+j4s2mc0v210aW6SztO228T2AN546QeCSKWkdQPAYrH KM6T/Yys+hLxCJ5mgHB7nwYp5gFSh2RAYD3yTSryIu6k/dOrH6nQ7xlvV7r6pmH+RVbe C1Jg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=otdJJ2oW; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-wireless+bounces-8697-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8697-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6ef62ef9besi24365366b.598.2024.06.07.07.44.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:44:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-8697-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=otdJJ2oW; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-wireless+bounces-8697-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8697-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id C57DA1F2631D for ; Fri, 7 Jun 2024 14:44:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DBAB19D09F; Fri, 7 Jun 2024 14:40:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="otdJJ2oW" X-Original-To: linux-wireless@vger.kernel.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 B899E19CD13; Fri, 7 Jun 2024 14:40:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717771250; cv=none; b=klpA1AiBsskUNcgd7vOFiif1t6c2MfUMxALd+4uKOkzdJmm8TcXoD5gfVpruMIN8uINmaI4C86GFscjUtv/Nu3fB/noAa3y9CfCZNRsV9NNVYuhRp6vf/Nxe1efGJrlGeY78tTbexDk/b3X6meeIcaRaoTiMLwALE07HuHHdv1E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717771250; c=relaxed/simple; bh=z7motuO/xV2ePFvwqk4C0YMsvJQ3jt9+be8vjhJjRHM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tKx8w2NXxWl/VKqMAYjRH5V6KOZeCInIVLngGELgE4xri5gWYqH94ejtpC3+QFudNVCgzpQRTT3Cc2gj36GIZaq19kwNPT58rghAkAaPvenTljo+I7LG9mohula1niOiXGMRX8vawOAfeE00YPsZEUI+gvit5X4xcIKEVXEQd3M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=otdJJ2oW; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 457C6rTg020987; Fri, 7 Jun 2024 14:40:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=qcppdkim1; bh=6RI6aD1aRcRnRr23fMfwPOE6 rq2EmxPFWYovc/OqDYY=; b=otdJJ2oWlb11pMI2okqFeQgoxX/d0L81MOWYhGMy y5b+oLZiahqUilD1EQaJIpjRPp66El92BvigXe5uUM/RxNR0wud4lyDPg5DaihIf DpYdBscLrE9s6fuI8pizAcDj7GuIkZ/bMg+AmPUsXca7mN6Oy4AFtgeJfSL2TBkr dZ8CvBUBx9uJWTa0Dxbdpig0eyjPkvzcRCPHrlEMjuXqODtnHe3RVsYnEzG+eGWm roarQidaY4toP1v+Je4Hkd6BKWNqE0HuDpdppPpEN75q2DFe4eNC7kXMJlW+l4Q1 A48nHuZy6/CXZPNg7DEh8mg1dxjdA+RvS8Ponqyl+Q5KvA== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3yk3h2vepc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 07 Jun 2024 14:40:38 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 457EebD7003199 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 7 Jun 2024 14:40:37 GMT Received: from zijuhu-gv.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Fri, 7 Jun 2024 07:40:35 -0700 From: Zijun Hu To: , , , , , CC: , , Zijun Hu Subject: [PATCH v1 1/2] net: rfkill: Fix a wrongly handling error case Date: Fri, 7 Jun 2024 22:40:11 +0800 Message-ID: <1717771212-30723-2-git-send-email-quic_zijuhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1717771212-30723-1-git-send-email-quic_zijuhu@quicinc.com> References: <1717771212-30723-1-git-send-email-quic_zijuhu@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: GZVKt2PTqVYl5BdnnRWTLMs1XgcBJ75P X-Proofpoint-ORIG-GUID: GZVKt2PTqVYl5BdnnRWTLMs1XgcBJ75P X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-07_08,2024-06-06_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 bulkscore=0 mlxscore=0 priorityscore=1501 clxscore=1015 suspectscore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406070108 Kernel API rfkill_set_hw_state_reason() does not return current combined block state when its parameter @reason is invalid, that is wrong according to its comments. Fixed by returning API required value, also use pr_err() instead of WARN() for this error case handling. Fixes: 14486c82612a ("rfkill: add a reason to the HW rfkill state") Signed-off-by: Zijun Hu --- net/rfkill/core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/rfkill/core.c b/net/rfkill/core.c index c3feb4f49d09..0dc982b4fce6 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c @@ -543,13 +543,15 @@ bool rfkill_set_hw_state_reason(struct rfkill *rfkill, { unsigned long flags; bool ret, prev; + const unsigned long reason_mask = RFKILL_HARD_BLOCK_SIGNAL | + RFKILL_HARD_BLOCK_NOT_OWNER; BUG_ON(!rfkill); - if (WARN(reason & - ~(RFKILL_HARD_BLOCK_SIGNAL | RFKILL_HARD_BLOCK_NOT_OWNER), - "hw_state reason not supported: 0x%lx", reason)) - return blocked; + if (reason & ~reason_mask) { + pr_err("hw_state reason not supported: 0x%lx\n", reason); + return rfkill_blocked(rfkill); + } spin_lock_irqsave(&rfkill->lock, flags); prev = !!(rfkill->hard_block_reasons & reason); -- 2.7.4