Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp422666pxb; Fri, 15 Apr 2022 02:49:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVhOqsQmyi28FXwW0VomOYHsSjqms/9ghmmZBYZDOxP/5rK6kPJ+/njI+WeGOI/ERnd63i X-Received: by 2002:a17:906:58d2:b0:6da:b635:fbf3 with SMTP id e18-20020a17090658d200b006dab635fbf3mr5467662ejs.40.1650016140304; Fri, 15 Apr 2022 02:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650016140; cv=none; d=google.com; s=arc-20160816; b=mniUgv3YoEJ9MLksnegWEJ8tv3TZONn1YeMjnakwOBLiK3MNbNPWrLUoJyvO8nlKIV BK3NuV7G0uabclzv+BrHo3hr1S5TEjTB/k+pBLFGUWeYQulbIu/X0IKNH0Qil+qcXPiu EOV1r9VduBV1to4VGanUkHssBXftuig//siVE9t79pOct6WStoJa8uZD7wazLMQfDMZq ruK0MPzyFukuIOoSyMpoo8NOwFI+3+HFKFMwtBn+L8fWMdQNXJ4vagI0KAAbcVwNaCFq xwIKRZqjGDG3gKxeRWzzVWcP87LjxZYsAz7Sr98w7GW3+FzdtTzAw8fN7s74HzrquopB p5nw== 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=xv2WORSiYHdZ2ZXzjz3lVxRLpW2YeRQ/OjMFwmEsen8=; b=co7dNaRkhSyb9q+rjTKO9ATy80QD64ofWXgyo4rLGG3h5pw8zEZWu+s1fKC0DkGXd5 8T+bUGDnJLQEeQ/o2fu0h08KqQ+94kxTJWbXTrhyD+B/WaHaG3BcLvdd9jbi1sl+vVWa PCjB9WkOjbWE9UfUqjVCBVQuqrlYW6JX5ezt8tvt5y5LSiKq6+Y5JyQP6j6dS5/FyPTE 9/BrpQG3THS+lv/8XFFUkHhraVVmRrFWvxNhb4YhGKIgCfZgLupxUi3sUucWMCWLOSdm yIr0DcMhijGiAF44cOThi1gF7xdjqmS2AZf8TkfNKjY8ARgQzNf9YVkcqL844rHn0HUC yIPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kq9-20020a170906abc900b006df76385c31si691315ejb.209.2022.04.15.02.48.33; Fri, 15 Apr 2022 02:49:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350027AbiDOFxQ (ORCPT + 99 others); Fri, 15 Apr 2022 01:53:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230224AbiDOFxO (ORCPT ); Fri, 15 Apr 2022 01:53:14 -0400 Received: from mail.meizu.com (edge07.meizu.com [112.91.151.210]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42B4B39BA7 for ; Thu, 14 Apr 2022 22:50:46 -0700 (PDT) Received: from IT-EXMB-1-125.meizu.com (172.16.1.125) by mz-mail11.meizu.com (172.16.1.15) with Microsoft SMTP Server (TLS) id 14.3.487.0; Fri, 15 Apr 2022 13:50:39 +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 13:50:38 +0800 From: Haowen Bai To: Greg Kroah-Hartman CC: Haowen Bai , , Subject: [PATCH V3] staging: rtl8192e: Fix signedness bug in rtllib_rx_assoc_resp() Date: Fri, 15 Apr 2022 13:50:36 +0800 Message-ID: <1650001836-25956-1-git-send-email-baihaowen@meizu.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20220415053116.GN3293@kadam> References: <20220415053116.GN3293@kadam> 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,SPF_HELO_NONE, SPF_PASS,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-kernel@vger.kernel.org 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. 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