Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp978915pxb; Fri, 15 Apr 2022 17:14:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzC2+NrWvDlnrEFsREKs5x45JyLVLqdenYYBQWxntOeudJ7ql32VutzBdOQOpg+HYzo93Te X-Received: by 2002:a17:902:c944:b0:158:de4a:6975 with SMTP id i4-20020a170902c94400b00158de4a6975mr1324270pla.131.1650068085327; Fri, 15 Apr 2022 17:14:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650068085; cv=none; d=google.com; s=arc-20160816; b=NkJgQLpklrxu4/oK7b4p1xqPqr038Sx0SXm2Q7Fb4yyah3dIlf76beP3vM72TWKdL9 ZIlofvrCxM6azjgc8WY9WZEsBnVglMuXyTntqoONCB2lQ/ZcKDGh78xjXh6coJy30Az0 qzCH5ui8zQeAQksM0wxArfPW1/NAk6I1MOJUF1/PQnIW3oCpWKySzshTNPRMWhIAVURR xLSXD9xGfep8gFju3DFHtngDHqFf+s0bt9d+vt0YlmUdNasg8EMUmS4vQTDRNO9/UU6S tl2ux0d064SC/J+Biac4xTq/qSA9dQzmAYno7lmo45hhiZSAdeYLGptZTKnQAkb/IaU1 Glvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=xMof/MKxd0oOzB61IQRUjCZfsBOdpLlEyISxwj72DP0=; b=HR5nyQado7VChWQJc2BYgbeT1wtrZDw3i6fc3PDMA/t5b5xPiMQSO/VyJn7+kZZFNI HxU0+pZY8n2viBnZSmJuz5KF9QOY16YrVNNLGGwz093OMOr6ExY/ZjXK93Gc/R+ZUBZ/ rgPiYnq6JEYlJewmKuMQpj4ClNQc774f7I8EP90p0D032chKcca2e50d15hLrcGRsH3O PChjHkfqfWK+7AqRbH2xz+AnegRCNrDmfGe44RmBd+dsoTEOdikMrANTiFnPVDj+VeuP SC4Ahn5u5xL608itxQkuFOnMXWLf8mwWr+IvsSnpj5wXgPzvNuysQ5fD1hTUCfyp69Gi AB0w== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id x16-20020a63fe50000000b003995115afc0si2814601pgj.519.2022.04.15.17.14.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 17:14:45 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CEDF367D2F; Fri, 15 Apr 2022 17:14:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350193AbiDOGSG (ORCPT + 99 others); Fri, 15 Apr 2022 02:18:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350192AbiDOGSC (ORCPT ); Fri, 15 Apr 2022 02:18:02 -0400 Received: from mail.meizu.com (edge05.meizu.com [157.122.146.251]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B5FE44A05 for ; Thu, 14 Apr 2022 23:15:30 -0700 (PDT) Received: from IT-EXMB-1-125.meizu.com (172.16.1.125) by mz-mail12.meizu.com (172.16.1.108) with Microsoft SMTP Server (TLS) id 14.3.487.0; Fri, 15 Apr 2022 14:15:28 +0800 Received: from meizu.meizu.com (172.16.137.70) by IT-EXMB-1-125.meizu.com (172.16.1.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Fri, 15 Apr 2022 14:15:27 +0800 From: Haowen Bai To: Greg Kroah-Hartman CC: Haowen Bai , , Subject: [PATCH V4] staging: rtl8192e: Fix signedness bug in rtllib_rx_assoc_resp() Date: Fri, 15 Apr 2022 14:15:25 +0800 Message-ID: <1650003325-26568-1-git-send-email-baihaowen@meizu.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <4370787.8F6SAcFxjW@leap> References: <4370787.8F6SAcFxjW@leap> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.16.137.70] X-ClientProxiedBy: IT-EXMB-1-126.meizu.com (172.16.1.126) To IT-EXMB-1-125.meizu.com (172.16.1.125) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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-kernel@vger.kernel.org This commit message suggested by Dan Carpenter as below: The rtllib_rx_assoc_resp() function has a signedness bug because it's a declared as a u16 but it return -ENOMEM. When you look at it more closely it returns a mix of error codes including 0xcafe, -ENOMEM, and a->status which is WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG. This is a mess. Clean it up to just return standard kernel error codes. We can print out the a->status before returning a regular error code. The printks in the caller need to be adjusted as well. Signed-off-by: Haowen Bai --- V1->V2: reduce return random value; print its own error message. V2->V3: change commit message; change s16 -> int. V3->V4: add message suggested by in title. drivers/staging/rtl8192e/rtllib_softmac.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 82bf05eb1cbf..4a1b9a94930f 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1764,7 +1764,7 @@ static void rtllib_softmac_check_all_nets(struct rtllib_device *ieee) spin_unlock_irqrestore(&ieee->lock, flags); } -static inline u16 auth_parse(struct net_device *dev, struct sk_buff *skb, +static inline int auth_parse(struct net_device *dev, struct sk_buff *skb, u8 **challenge, int *chlen) { struct rtllib_authentication *a; @@ -1773,7 +1773,7 @@ static inline u16 auth_parse(struct net_device *dev, struct sk_buff *skb, if (skb->len < (sizeof(struct rtllib_authentication) - sizeof(struct rtllib_info_element))) { netdev_dbg(dev, "invalid len in auth resp: %d\n", skb->len); - return 0xcafe; + return -EINVAL; } *challenge = NULL; a = (struct rtllib_authentication *) skb->data; @@ -1787,7 +1787,7 @@ static inline u16 auth_parse(struct net_device *dev, struct sk_buff *skb, return -ENOMEM; } } - return le16_to_cpu(a->status); + return a->status; } static int auth_rq_parse(struct net_device *dev, struct sk_buff *skb, u8 *dest) @@ -2282,7 +2282,7 @@ rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb, static void rtllib_rx_auth_resp(struct rtllib_device *ieee, struct sk_buff *skb) { - u16 errcode; + int errcode; u8 *challenge; int chlen = 0; bool bSupportNmode = true, bHalfSupportNmode = false; @@ -2292,8 +2292,8 @@ static void rtllib_rx_auth_resp(struct rtllib_device *ieee, struct sk_buff *skb) if (errcode) { ieee->softmac_stats.rx_auth_rs_err++; netdev_info(ieee->dev, - "Authentication response status code 0x%x", - errcode); + "Authentication response status code %d", + le16_to_cpu(errcode)); rtllib_associate_abort(ieee); return; } -- 2.7.4