From patchwork Fri Oct 9 17:13:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 11826915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B9A6C433E7 for ; Fri, 9 Oct 2020 17:13:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B23A22265 for ; Fri, 9 Oct 2020 17:13:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="gHjP/gJQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390058AbgJIRN3 (ORCPT ); Fri, 9 Oct 2020 13:13:29 -0400 Received: from mail-eopbgr760043.outbound.protection.outlook.com ([40.107.76.43]:44295 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732488AbgJIRN1 (ORCPT ); Fri, 9 Oct 2020 13:13:27 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kaaes68viLjGdWWeQr/JIwcQeJ4wcAUfje+JwhRwKnXYMWhKJ4TGnOJzWGfYD4UD5xxXWIogHCpdSNVQasTK4OJVQ9Bnj+pt9o8YKwBpqAPxIcQptxkUihm8gkG7RO1E+vIcy6PeA2vEizvsShpSlGQlAKIETr7YdzR8QOlJAIyRcuZeQC/9PoXfDsmuRv1aLgf2f/sHZEpF//FPg66wvvR1nr0DoEw9knaBP0Bhr38SRFGgIPC2wWusejNlUAqAz0DESODsnXBQJk8cf+FH6YcJc8Y7YomrOT8sOL9cp+V6QdzhDPdxLwQymVygMWUM8B4bJtzCmoSBxbpi5KexLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=80BDLOHA2/Tyf/HJKSMkGnqFDkkFta57/fObreAjjKs=; b=E8dFhBqkTAd5/GA0I07RDq3LwlgQGG5sM7efgQOilZnktOg74jwJzxNZiMa4T4GX8mSS6OHKo00t3QOJmvvTKLGV4KEIx82zXTASLV0dMEvhdsWESD8zX2NVSXICg02PLxHNiaJOgerev6sZeq8WS6Ci6rh4acnxT+z4tpC1M2tTIiN+mCXoW9MSF92SVzvD5V2PNoo4LCACytlJC3DYBwoSH75HtXs9UBoIYdEzZm/PyesTNG2+kz8rf4qPEM9oK7ygX+6Kl482vv95Kh7dQjM5Zhpl3qdvOt8Z+fS8YLK/dS5T6PhKcM/BERfQ/iDmszYY1mUqjCNG93haqWUG0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=80BDLOHA2/Tyf/HJKSMkGnqFDkkFta57/fObreAjjKs=; b=gHjP/gJQxoGz5NYwFNOUqer2JhqMoJR+7vayBGu0FedK2mvnQQkir7c4a1K/04G23Htw4zY4C1xhegGyEflmVn/ygU0GziG2qP+QSY6MvE8lj8+8fCPROFGNnLoGy4BFRrdiSrPs5B0bf6H/EzUsbrXkkVaqFOm61GBiEBPhzGU= Authentication-Results: driverdev.osuosl.org; dkim=none (message not signed) header.d=none;driverdev.osuosl.org; dmarc=none action=none header.from=silabs.com; Received: from SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) by SN6PR11MB3455.namprd11.prod.outlook.com (2603:10b6:805:bb::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.22; Fri, 9 Oct 2020 17:13:24 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a%5]) with mapi id 15.20.3455.024; Fri, 9 Oct 2020 17:13:24 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , Dan Carpenter , =?utf-8?b?SsOpcsO0bWUgUG91aWxs?= =?utf-8?b?ZXI=?= Subject: [PATCH 1/8] staging: wfx: improve error handling of hif_join() Date: Fri, 9 Oct 2020 19:13:00 +0200 Message-Id: <20201009171307.864608-2-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201009171307.864608-1-Jerome.Pouiller@silabs.com> References: <20201009171307.864608-1-Jerome.Pouiller@silabs.com> X-Originating-IP: [82.67.86.106] X-ClientProxiedBy: SA9PR10CA0004.namprd10.prod.outlook.com (2603:10b6:806:a7::9) To SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.silabs.com (82.67.86.106) by SA9PR10CA0004.namprd10.prod.outlook.com (2603:10b6:806:a7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24 via Frontend Transport; Fri, 9 Oct 2020 17:13:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a8e7d44c-fb61-4be2-c7f7-08d86c76a0fe X-MS-TrafficTypeDiagnostic: SN6PR11MB3455: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DljSLcqYJ9vUTrTBy7lpPO78v9FoFB846WTGrNYskwrqgmimzfdWAJF+x/uly3pCU4qHlOx0JaoBCndJ1mVsoe13B6VZamDt20k7IkmEdvscy+TuaV1A+bT1P/1aXdXFLgPvXWKBV/1pvOjeDegVT+TbGUMeGzOdc7AHA1DPg3hXgQ+0aKXKUKKC3zAY+cZtfdEt3qkb2DAZyShQogJNrCX3r+SOvcxTM4SXEBJdc9QqJixYC5eCl8Oir+A0cu36qIbc56hPAtXZFDGT1d+IIAx12aVF9UxEorkNkzL0fWr41RxAwvlcHSYiW2KGZ6aQ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR11MB2718.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(346002)(376002)(39850400004)(396003)(136003)(8936002)(36756003)(54906003)(1076003)(316002)(52116002)(7696005)(2906002)(5660300002)(478600001)(66574015)(86362001)(4326008)(66946007)(66556008)(66476007)(6666004)(107886003)(26005)(16526019)(2616005)(83380400001)(186003)(8676002)(956004)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: TxFiOzjzxrvzXC9Q7cnECmSHHjmbkCQAAgf5ipkMF/799ayLIMmXP5yLPMa8xBb4yReuLuOiwqEPoz0N3hCREhn4k25ubG6n0un8vys5I3Qngz7WKPko4h6Jzsjy8z2xTzfPNfPudmyh3nUupx13Ia2h7DsSM5oQpBZgiWOx2iKLFdcHUKr1bkM24CsrijgUK1lFHpxpoRzdk8f4f79fOgKb4cDuXiWS3GFhPZ427RUSW9bZIm3ERDl177UPmbqemOMW4OOFe/5sg51389vQdazDRqOJyB/z8xdTSVo9jGzqnsOk+koOwzITQR74yNJnW54FFJ/cz6t1Dwk1O7yV1iD8Qjg5+eXecA9+kuNjAJDwPXZIQHpJ7MYpwKhMV80tv4Gfa/FOuD/VrCtvgZ9weHgmWhEdzK5X5svXn1rQEv2VCqSRkcNEc9Kyr5Aesg/pXRTjjaLlyIgVb+a2qTcQ1YVc6HtDpql+tpaLGyMsY9Y4o6pEwZ6hOXrGxan9Uig8zEqpkKKokxqcHatzxtwhMBAe3cEqyQvr6fAhAQqYIaQd76ucsszf07fUS8AmU0vEreUREttHFathekVgbrYeqHFHqqpBZqQl9+zCms+42+Evaw/m2c3law3gEdZ2u6d+EXXp+3x7TV0cF+6Mp7Qgfw== X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8e7d44c-fb61-4be2-c7f7-08d86c76a0fe X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2020 17:13:24.1414 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: saFzmPS0W9sBG6p2g8qZM4bwqmQQecnT1oVkseS15Bntx+pDPmzykU64fFIkNelslvhoDOJcS/PUEcVwbuCKpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB3455 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller Smatch complains: hif_tx.c:319 hif_join() error: we previously assumed 'channel' could be null (see line 315) 311 if (!hif) 312 return -ENOMEM; 313 body->infrastructure_bss_mode = !conf->ibss_joined; 314 body->short_preamble = conf->use_short_preamble; 315 if (channel && channel->flags & IEEE80211_CHAN_NO_IR) ^^^^^^^ 316 body->probe_for_join = 0; 317 else 318 body->probe_for_join = 1; 319 body->channel_number = channel->hw_value; ^^^^^^^^^^^^^^^^^ 320 body->beacon_interval = cpu_to_le32(conf->beacon_int); 321 body->basic_rate_set = Indeed, channel can't be NULL (else I would have seen plenty of Ooops this past year). This patch explicitly claims this restriction. Reported-by: Dan Carpenter Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/hif_tx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c index e61cc2486761..63b437261eb7 100644 --- a/drivers/staging/wfx/hif_tx.c +++ b/drivers/staging/wfx/hif_tx.c @@ -308,11 +308,13 @@ int hif_join(struct wfx_vif *wvif, const struct ieee80211_bss_conf *conf, WARN_ON(!conf->basic_rates); WARN_ON(sizeof(body->ssid) < ssidlen); WARN(!conf->ibss_joined && !ssidlen, "joining an unknown BSS"); + if (WARN_ON(!channel)) + return -EINVAL; if (!hif) return -ENOMEM; body->infrastructure_bss_mode = !conf->ibss_joined; body->short_preamble = conf->use_short_preamble; - if (channel && channel->flags & IEEE80211_CHAN_NO_IR) + if (channel->flags & IEEE80211_CHAN_NO_IR) body->probe_for_join = 0; else body->probe_for_join = 1; From patchwork Fri Oct 9 17:13:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 11826925 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E33DC433DF for ; Fri, 9 Oct 2020 17:14:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D41222258 for ; Fri, 9 Oct 2020 17:14:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="UlzW7vll" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390120AbgJIRNm (ORCPT ); Fri, 9 Oct 2020 13:13:42 -0400 Received: from mail-eopbgr760074.outbound.protection.outlook.com ([40.107.76.74]:48911 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732488AbgJIRNd (ORCPT ); Fri, 9 Oct 2020 13:13:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ipMie+1kAjsJKmk5z5eQ8/ZI1BbbSTuYHGyTmB43gh1quCD8nT2icBpX5RYzH/k85abx/zOd9MicKwHYZWC8FK/Lgeb01I0Oxxo94zOkO0Bg6QmqDyep38O0IQntUg7LbMQf2ToRl7lIdaqal2L9E4naUUOiXIWDDDakznQVZj7FNsQDT+79Bm2/xWAACI2OX+cX5MhlHL5gR3zHE5l+K/Ggf82vKCVKSaJojfLmeAbnlbNPomw8ZxVgwnQeLQqEegS6ZSVMPgiHA01jOaXptu/6w4hnV4kZDr5jk53pkpQoSyAweg0RohLxGx/icKt7MjYIUqXdoBt+LgS9I0zXdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uQt70Y/LPjZH5xiGV8CtR5xvL0XVIYWyKXWcFkSGMBg=; b=JpkW5B+AqtSEN2IP+yJ2BoEQLFKy4aJBMKD3Teq69p6rNUn7eteq9RCpv7wra8xSpnw2PxbIN+byDkAwZu8xr5TmTorDj+p+6mY3lPC8efQUkE+dOpCwXqX2kT7bxREnwuiJuRQDDc15zo+lhkWgAkWvoIzZrVzn8ScWOvZCIwfWQK2xzOqYZhq1wfdEQqitZGg9bWxMYonrY6K50Apuiz4E+3OGd1pgloKHzeWWHP8URELyhCirpEcEgOr38yU7Puh3V4DLizdpdhXHEma3MbTEPLJwyuwf1XfLxzD4+PyFxUgqwsHpGO1f+purnEhluk6QUdnlxUK/Bz/OMrUrRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uQt70Y/LPjZH5xiGV8CtR5xvL0XVIYWyKXWcFkSGMBg=; b=UlzW7vllx1MVMpA5P7GStxkGQwhAlzzojkPcO02EynKDd/tL5iHtxmakze3OLE+1dr5FuNR08sgETaIuwRiXhPOnMd8eoG3X1rnsCxIkH6I1kIYQGQgrrqsqojndWYWOkuJTPCIk9O5Ij+LUV87OTWAmhS2p68Pl6FW/gB1ROXo= Authentication-Results: driverdev.osuosl.org; dkim=none (message not signed) header.d=none;driverdev.osuosl.org; dmarc=none action=none header.from=silabs.com; Received: from SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) by SN6PR11MB3455.namprd11.prod.outlook.com (2603:10b6:805:bb::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.22; Fri, 9 Oct 2020 17:13:28 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a%5]) with mapi id 15.20.3455.024; Fri, 9 Oct 2020 17:13:27 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , Dan Carpenter , =?utf-8?b?SsOpcsO0bWUgUG91aWxs?= =?utf-8?b?ZXI=?= Subject: [PATCH 3/8] staging: wfx: standardize the error when vif does not exist Date: Fri, 9 Oct 2020 19:13:02 +0200 Message-Id: <20201009171307.864608-4-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201009171307.864608-1-Jerome.Pouiller@silabs.com> References: <20201009171307.864608-1-Jerome.Pouiller@silabs.com> X-Originating-IP: [82.67.86.106] X-ClientProxiedBy: SA9PR10CA0004.namprd10.prod.outlook.com (2603:10b6:806:a7::9) To SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.silabs.com (82.67.86.106) by SA9PR10CA0004.namprd10.prod.outlook.com (2603:10b6:806:a7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24 via Frontend Transport; Fri, 9 Oct 2020 17:13:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 50745ac1-2daa-4cf9-3c3a-08d86c76a358 X-MS-TrafficTypeDiagnostic: SN6PR11MB3455: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1751; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0cTaCDFgiJbIJShhdTmWv44GEgOOebkTn/YiaukrcJ//KjPMErfv8fVtbfYf+iBut2OPkCzmuwTgpZLO42cqj2Tk50z9qUHdwstnOO2TtiRpPBoB1c5H8YDjVvYr17F6yeOXWjWmx4jA+ZkMhY0+pIvkScmGmF2kM+fCqx6KUpX34qX3fc/MlU4mgXlzdgZDK3I+OtQ1kekzGPqmBg+V1JsD+GYWr+wf94fhcHKsjjDM/UjyGMhAOAXwyq18QUEeyrFblHzfspkaS6eIFXPAkOqpfau0MsifBFjvDMxlJucKjXhntWw7/pMApXlYx9YMeqYbCkro8owbehHQG9EnqA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR11MB2718.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(346002)(376002)(39850400004)(396003)(136003)(8936002)(36756003)(54906003)(1076003)(316002)(52116002)(7696005)(2906002)(5660300002)(478600001)(66574015)(86362001)(4326008)(66946007)(66556008)(66476007)(6666004)(107886003)(26005)(16526019)(2616005)(83380400001)(186003)(8676002)(956004)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: +B5GaRfJ1OTE66YUAoc5mtllAer2DWFfJOdbnwR54vQKS9WdzcYc3Jlprj9mxZz0uQnujtNWDuIAjii+fYke/fjh2ghXkWTSvXtK4cwlLAXEH7EJegKruVorupVxlCHIQSOO+qIPy/7b8/tSSLT5kgDDAtWxl2+AnUkuIOERJISY3qryjwbU9zRWSN5x+8aMxT4o1FH0JimhW0Ihv3zYbdSJLdzQ7YN8jg6yGjLBgIgEcB8/LO8Qq0Natjsyts5kVVxEMt7B2WTmKsGDa5OTOZoUvmH52VGO4fljQAoVMq6spL45RRNi8hzVwsm4j80i1IBAnmVoUqVdSJlBeUjJlLLivTDTF8ABkcmNqi+8Hue9NWfGfDMzAkn1wRexZAiiXlMzkjF8u/78eJgxZWutm7jMPwZSKoQ+Qr1A6yYvVqc1x7qCeosCvi2jx4E0fT/Bzav3OJ1bvL5g5Tj08hwKccXsVKdfOfteMv1rm5ibyZ2BKd9lG6GU1NKCOoydw13xv7adgFf7w/Iq/ezwWrMvycV/NoXv16v3pKzsiGfXAvsHhdeloM9TP1NXBUs3WCM2FFzy+7RhoYy74ZvjhfgPXS/oMJ+k3MhCl2dhH+Bq8DsDf3UvvAWMS87C5sn1Ec/IkAJrTX7yzW620zbaLsLEgA== X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50745ac1-2daa-4cf9-3c3a-08d86c76a358 X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2020 17:13:27.8153 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Hd3YAZXdDBfJwd6CJ75t+2yOv9DP6BgJ3EFNwd2QB324uE3tpGftLT01yrYe6cVFgsNPshMvKX6xbTxy+LlIRg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB3455 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller Smatch complains: drivers/staging/wfx/hif_rx.c:177 hif_scan_complete_indication() warn: potential NULL parameter dereference 'wvif' drivers/staging/wfx/data_tx.c:576 wfx_flush() warn: potential NULL parameter dereference 'wvif' Indeed, if the vif id returned by the device does not exist anymore, wdev_to_wvif() could return NULL. In add, the error is not handled uniformly in the code, sometime a WARN() is displayed but code continue, sometime a dev_warn() is displayed, sometime it is just not tested, ... This patch standardize that. Reported-by: Dan Carpenter Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/data_tx.c | 5 ++++- drivers/staging/wfx/hif_rx.c | 34 ++++++++++++++++++++++++---------- drivers/staging/wfx/sta.c | 4 ++++ 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index b4d5dd3d2d23..8db0be08daf8 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -431,7 +431,10 @@ static void wfx_skb_dtor(struct wfx_vif *wvif, struct sk_buff *skb) sizeof(struct hif_req_tx) + req->fc_offset; - WARN_ON(!wvif); + if (!wvif) { + pr_warn("%s: vif associated with the skb does not exist anymore\n", __func__); + return; + } wfx_tx_policy_put(wvif, req->retry_policy_index); skb_pull(skb, offset); ieee80211_tx_status_irqsafe(wvif->wdev->hw, skb); diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index d6dfab094b03..ca09467cba05 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -110,9 +110,9 @@ static int hif_receive_indication(struct wfx_dev *wdev, const struct hif_ind_rx *body = buf; if (!wvif) { - dev_warn(wdev->dev, "ignore rx data for non-existent vif %d\n", - hif->interface); - return 0; + dev_warn(wdev->dev, "%s: ignore rx data for non-existent vif %d\n", + __func__, hif->interface); + return -EIO; } skb_pull(skb, sizeof(struct hif_msg) + sizeof(struct hif_ind_rx)); wfx_rx_cb(wvif, body, skb); @@ -128,8 +128,8 @@ static int hif_event_indication(struct wfx_dev *wdev, int type = le32_to_cpu(body->event_id); if (!wvif) { - dev_warn(wdev->dev, "received event for non-existent vif\n"); - return 0; + dev_warn(wdev->dev, "%s: received event for non-existent vif\n", __func__); + return -EIO; } switch (type) { @@ -161,7 +161,10 @@ static int hif_pm_mode_complete_indication(struct wfx_dev *wdev, { struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); - WARN_ON(!wvif); + if (!wvif) { + dev_warn(wdev->dev, "%s: received event for non-existent vif\n", __func__); + return -EIO; + } complete(&wvif->set_pm_mode_complete); return 0; @@ -173,7 +176,11 @@ static int hif_scan_complete_indication(struct wfx_dev *wdev, { struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); - WARN_ON(!wvif); + if (!wvif) { + dev_warn(wdev->dev, "%s: received event for non-existent vif\n", __func__); + return -EIO; + } + wfx_scan_complete(wvif); return 0; @@ -185,7 +192,10 @@ static int hif_join_complete_indication(struct wfx_dev *wdev, { struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); - WARN_ON(!wvif); + if (!wvif) { + dev_warn(wdev->dev, "%s: received event for non-existent vif\n", __func__); + return -EIO; + } dev_warn(wdev->dev, "unattended JoinCompleteInd\n"); return 0; @@ -195,11 +205,15 @@ static int hif_suspend_resume_indication(struct wfx_dev *wdev, const struct hif_msg *hif, const void *buf) { - struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); const struct hif_ind_suspend_resume_tx *body = buf; + struct wfx_vif *wvif; if (body->bc_mc_only) { - WARN_ON(!wvif); + wvif = wdev_to_wvif(wdev, hif->interface); + if (!wvif) { + dev_warn(wdev->dev, "%s: received event for non-existent vif\n", __func__); + return -EIO; + } if (body->resume) wfx_suspend_resume_mc(wvif, STA_NOTIFY_AWAKE); else diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index a246f0d1d6e9..2320a81eae0b 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -619,6 +619,10 @@ int wfx_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, bool set) struct wfx_sta_priv *sta_dev = (struct wfx_sta_priv *)&sta->drv_priv; struct wfx_vif *wvif = wdev_to_wvif(wdev, sta_dev->vif_id); + if (!wvif) { + dev_warn(wdev->dev, "%s: received event for non-existent vif\n", __func__); + return -EIO; + } schedule_work(&wvif->update_tim_work); return 0; } From patchwork Fri Oct 9 17:13:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 11826927 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56B21C43457 for ; Fri, 9 Oct 2020 17:14:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 04BE52231B for ; Fri, 9 Oct 2020 17:14:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="o82f8+3I" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390210AbgJIROR (ORCPT ); Fri, 9 Oct 2020 13:14:17 -0400 Received: from mail-eopbgr760074.outbound.protection.outlook.com ([40.107.76.74]:48911 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2390102AbgJIRNn (ORCPT ); Fri, 9 Oct 2020 13:13:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wb0t7e+G+YmPOUJUALP+aE7crrYqPZEGTYtSCAYXI/Qwbom8TXNtLqSrTv+A/1FgHRSuOj11ZTt36bHLdkNk18Br511Nyl02uz8Gr9auYlUEhipZpa83J6tSslahqGEmLRFR3vDfbv9Kr3N7E4hCgUxUJjQWJ8q8zFKW2bfl9VxkrFaZ+kFzBS2e0IS6dunFE3bW69d0kxUdLnJwRpZeUKnLnhw30FmoUBz3/BTOtLl/eKcZodbyAbcz4BGDswEgQGWDAVjc8qRE642ZtwVj0UARqLVndOX5NGFSW+evj7QmKLOXaIbwioAe6Hx7wR11M0UXubQUwRC69aoctlaVnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dSt2vbIr2iX+8KYioDJs37B0bMyliE1X+LgFMy1ISgU=; b=oWio+ASIz6PIqPHcIP2st6+COKVt5wiwPL+NtgejWQ5jXSnHNuLSq/zWUfgMPjmUYOiJDD/X1STaLIGT6YU2tflRM14g4bmuzEC5zsDByviClV7zl2m7eQ+1giLOjpfprDG2yV7SwY9DSsFHGWEc2JhijQlUbvsbWoHHm7aUqzJ9yT7uttEWxRa4Z/xJMQyE4KyYjiOwoslEE+IM3wl21y4YuANUEEkSSWc2snxyFETAo3GbqVHsMXwAI+GvANJ/rw1y0dl3oGTFOYkR4EGLxMKNQssd6DLA8AEcpVp/kvRH/G5Ucws/1UoSpSKVZiofmc+f0jY5fmbmPpGx3JhXXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dSt2vbIr2iX+8KYioDJs37B0bMyliE1X+LgFMy1ISgU=; b=o82f8+3I1koBBpNbqNeQUHFCgx8Ee/7DbiUObRSLSLbYOGG5It+M2d0pM58JB8cY0bPe7QCCbA6ScWeRvmFPXMxqLlCaDA6hAxixi0R064cZsHWxcfwj3nqDwK6Mic4SRSYZpS9WhkE3NN7Q4wQQ28tpBYFc2UcIDYxJKzGkNqo= Authentication-Results: driverdev.osuosl.org; dkim=none (message not signed) header.d=none;driverdev.osuosl.org; dmarc=none action=none header.from=silabs.com; Received: from SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) by SN6PR11MB3455.namprd11.prod.outlook.com (2603:10b6:805:bb::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.22; Fri, 9 Oct 2020 17:13:29 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a%5]) with mapi id 15.20.3455.024; Fri, 9 Oct 2020 17:13:29 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , Dan Carpenter , =?utf-8?b?SsOpcsO0bWUgUG91aWxs?= =?utf-8?b?ZXI=?= Subject: [PATCH 4/8] staging: wfx: wfx_init_common() returns NULL on error Date: Fri, 9 Oct 2020 19:13:03 +0200 Message-Id: <20201009171307.864608-5-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201009171307.864608-1-Jerome.Pouiller@silabs.com> References: <20201009171307.864608-1-Jerome.Pouiller@silabs.com> X-Originating-IP: [82.67.86.106] X-ClientProxiedBy: SA9PR10CA0004.namprd10.prod.outlook.com (2603:10b6:806:a7::9) To SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.silabs.com (82.67.86.106) by SA9PR10CA0004.namprd10.prod.outlook.com (2603:10b6:806:a7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24 via Frontend Transport; Fri, 9 Oct 2020 17:13:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 88c95c4b-e0c1-46c0-eeac-08d86c76a476 X-MS-TrafficTypeDiagnostic: SN6PR11MB3455: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:392; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6F7w/PQgjMpjhZITDYNLJKg83WogApdq/x1BcAwhMUEvuqS0BtMIfj8UwWlrfCASKWatadIvJlNHjgiVlsn/uISxRKao0AI17b+F0BWuDdXI5B71THwlP9ApEQCE80czl0cu3uXmkgZhCJbXffKFGA6lSBUr2t8CNXnL6oL2uDq535sPy+5Mg7f59dap3Pjv1yY24qwXu5sMGzg5b+mHHejKzBYGq2GsLc/piW9iGpTiZ2LAARiOGtQcD3wckrg7l0Tux8SjS6Qlw81aUDy2p6ILmHbOaMaWfNdx/hXeEI8Mmp2GgP3RzjIvtAJ7JUfKzz3DFlQq7VbbPsZb8QPG2A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR11MB2718.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(346002)(376002)(39850400004)(396003)(136003)(8936002)(36756003)(54906003)(1076003)(316002)(52116002)(7696005)(2906002)(5660300002)(478600001)(66574015)(86362001)(4326008)(66946007)(66556008)(66476007)(6666004)(107886003)(26005)(16526019)(2616005)(83380400001)(186003)(8676002)(956004)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: P131R5G5cMUPWoR32FkNYMR9qVowtJogi/NJDntiDzN8rSQjdKmXR8rGX3w6VQ5Fwo2YagACEBHEdqosYlvmS3hPGWp6HvT3kpUttSNuiKyNzD4/8YmCzg4COMjaLGwQjdmK2mmbHzpgrKbPSLWY9IrA0adt+LR4iWMTqvqRFEADvEjaYwoZD9Gi0iAzrXtBqOGaKT7awusU5vA9hdp4ERhh57svpP14PdcsDGg8rSxZhbM+pNiSc4gGvXjsmJQuAZwPRH4CB8/YPp8Ldu+drHL1WQI6O636KVfO2nYctkhvRy+W159Mq18sXgGxF6MuEZU0uLzd0JYHNCZILs9Pve3SRrrgyhU6h707lPRuuOIFGcpoc9Gmk+oJSvMDR7LOIAZLKyNz8qZwS5gIE2j9H8qMGtfkXXI3SPL8rRoVoNA6FuIHmWXr6j1Z/ZYxcAIGicfV8F6jY+lhISbmTFPsXKYLtECh+5GpP/A8SnWw+42XZkUB1yh10Rt1Kphhe1s4oqI1ggtLD6uudVko/GxxjG1v4YVDccrBon3ZyMT2ybrFh3EuavY4xm1r4JKPeQHf6Fmye51aXfsqb89LcvL67ZoZ5vC77wMNrBIbUMTiQQnKMJ0WgG3hrQD5SWhGEhsMC+kR2ZgoACV9v2hzBSzucg== X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88c95c4b-e0c1-46c0-eeac-08d86c76a476 X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2020 17:13:29.6502 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Fh3NTCZoN1DLokwJ6xRP77qO8UIXi3ZX8tOl15CLELlDZywIGoEFNdglEqV82iesGfLlRexBUJESJ5WLM/nzIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB3455 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller Smatch complains: bus_spi.c:228 wfx_spi_probe() warn: 'bus->core' could be an error pointer bus_sdio.c:221 wfx_sdio_probe() warn: 'bus->core' could be an error pointer bus->core contains the result of wfx_init_common(). With this patch, wfx_init_common() returns a valid pointer or NULL. Reported-by: Dan Carpenter Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index a8dc2c033410..e7bc1988124a 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -309,7 +309,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, wdev->pdata.gpio_wakeup = devm_gpiod_get_optional(dev, "wakeup", GPIOD_OUT_LOW); if (IS_ERR(wdev->pdata.gpio_wakeup)) - return ERR_CAST(wdev->pdata.gpio_wakeup); + return NULL; if (wdev->pdata.gpio_wakeup) gpiod_set_consumer_name(wdev->pdata.gpio_wakeup, "wfx wakeup"); From patchwork Fri Oct 9 17:13:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 11826917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04AB5C433E7 for ; Fri, 9 Oct 2020 17:14:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BDCF522258 for ; Fri, 9 Oct 2020 17:14:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="HwpLplVe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390177AbgJIRNu (ORCPT ); Fri, 9 Oct 2020 13:13:50 -0400 Received: from mail-eopbgr760074.outbound.protection.outlook.com ([40.107.76.74]:48911 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2390148AbgJIRNp (ORCPT ); Fri, 9 Oct 2020 13:13:45 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NBvYZ73B3kZIPoOowYMaiHN0W+BXoGcFx7j0nlQFrxlg8QtoyL0Rh6A996BCU1+/sI71eQEPJiE8U8zi5JSuYJyNP2ro8WiwDZKWgE5aLXWngrhLFb1LIyfi7L/lRlXXKmtJTOt7MNtK1ScZRyBOIdDybGJ7g71ogp++SPj9xS3zFyjkwhBZTwMao8fywz4v7VXmq1SkyoZNrMd8JfL5XnXR6wJT9nqX1cAFUqyc1EQnN54yG73S8Js/VNQj9ee9IJagi1OM29FR9EQPtT2jq4wpMnKB8lSviuBsm84zUiDv0HlmIyPALF2XXg/fh77FKhTYTSIDvsHEfoZ2wFDIBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gFamtZ+oLsXr5s+k5oJSr9zgVd2lARoDpqvQrwygSkI=; b=W7UeOmylrbNDKqid79upbMYTMgH+7vJVIqX5HMXsFkyVrCr6H58SHVcRf0izJN20rp78su6R0Cf4DS0NzQvn2tr0tbNNLQcE8W/43+y2ELQUpS/yEUdEPAYzkHBwhGOURgryM4o+RrMVUYdL3CMfcbpASQZUC5VyHDqmj+ld96SkvYUzCZJ/kweAW9dUHe0mX5PP3bMlGHRoxUJVIMCP80KJBKGgufsPrunDn/z5jJlC1wu+Qrj0hQ2e47dBBup+3DEYMQ+Z4+hE7e5GAUDJyooxkhwDzZXC7p5jormf0aHsRlZovvh/Qzncga7tBSXCA3bYEnXwspUoCq2bjjZTAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gFamtZ+oLsXr5s+k5oJSr9zgVd2lARoDpqvQrwygSkI=; b=HwpLplVePJQhgklHZKsiG1LMxP5ro7ZpvMZA6f0alnIaOpMAStVzrtWEkbZbBYx7SEGlPbrZgTpvIOb7cy7hznbGBvVQNkK0YDVmYBLXnT9fOTEXSMynqZ+bQ+jGhGpn3tCKQTeU7XORz+g8olbaEcQCQWR0RAFLyPHmN4A9lHQ= Authentication-Results: driverdev.osuosl.org; dkim=none (message not signed) header.d=none;driverdev.osuosl.org; dmarc=none action=none header.from=silabs.com; Received: from SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) by SN6PR11MB3455.namprd11.prod.outlook.com (2603:10b6:805:bb::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.22; Fri, 9 Oct 2020 17:13:32 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a%5]) with mapi id 15.20.3455.024; Fri, 9 Oct 2020 17:13:32 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , Dan Carpenter , =?utf-8?b?SsOpcsO0bWUgUG91aWxs?= =?utf-8?b?ZXI=?= Subject: [PATCH 5/8] staging: wfx: increase robustness of hif_generic_confirm() Date: Fri, 9 Oct 2020 19:13:04 +0200 Message-Id: <20201009171307.864608-6-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201009171307.864608-1-Jerome.Pouiller@silabs.com> References: <20201009171307.864608-1-Jerome.Pouiller@silabs.com> X-Originating-IP: [82.67.86.106] X-ClientProxiedBy: SA9PR10CA0004.namprd10.prod.outlook.com (2603:10b6:806:a7::9) To SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.silabs.com (82.67.86.106) by SA9PR10CA0004.namprd10.prod.outlook.com (2603:10b6:806:a7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24 via Frontend Transport; Fri, 9 Oct 2020 17:13:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 55c31237-5da1-4da5-1254-08d86c76a5cc X-MS-TrafficTypeDiagnostic: SN6PR11MB3455: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2399; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k6xJxDPNrx1xeQSJ4CvK7qH4MKNdh3mDrbKkZsn60S/4dskwe+xHxZG7au/IsrdFBeUJfv5uusZyyIQVWqeULFd6MTkX1Kd0AZUEk7oadXQkbtVTwGHaaD1we53uMNPSTZQhLbYvfugAS7uicw62wVCXo4+yKkPK6bzZg9/AKfC06wpPW/rmDSbS2/W44bs+jn+VL2IQA/BVb/Jw722cXzntnVrh5914ZutoGqMcs0rfPB83cSgxfFoCPchi+dejQNmXMeH1yr/r9JYdWdc3dtzKSeW5F77r+SRlOm2iMwXNeC1UQ/A8P+GKNGdZdtv3DXEnOIUqKAHto6vd89HW+zkqIPU/ZrnyOO96wJhjq2PH0f7Qcx0WCygvRKdnb5aE X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR11MB2718.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(346002)(376002)(39850400004)(396003)(136003)(8936002)(36756003)(54906003)(1076003)(316002)(52116002)(7696005)(2906002)(5660300002)(478600001)(66574015)(86362001)(4326008)(66946007)(66556008)(66476007)(6666004)(107886003)(26005)(16526019)(2616005)(83380400001)(186003)(8676002)(956004)(6486002)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: D/38gC1g/3u8VoaBRMtRZf748kKMNequ7C0RWSafUyF+xvZo+3nKSTnmj7HQbdABVU6eZssim7N05nB8cmDAEzYZYpKPk3zCxseAG+euJizQGK617uWkevyfK+OyZdTCrqCWE3gsM3NmosWImBTG3ntRC8Wih6cJh5A5PDQfI8KaNilLaRXw5fzeKdHUg+VFKtczTZtPO26g1PJ1TtcvafXQhi5B2esyQoqfsZTQM/CIVoyVq8vINAAPneC1j5yyd2Ko5VoSMW/oKw9Gfp751u0C9LiZwi9FZdRC8Rp0o6bgF0RO4PCtvhUTjKtVXWIjnEmugsRu4SEgERBH0myE/Q3R+3H4iiwnWYC1YxGW/Cx7YPtqemWtlkgAeaPhw3+MZD124n1kpnpfacW5R6GSKKAG9YXhH6q+HaeDTVabsaHC5Qu6pM2SBFxGowB3MwLlYwZyZYJeEHrySbXlzdgmY/NX+7DdryVXLrg1ohNw841UUmoswxRn8cxo4a6pBXauP6xR6KWE/G5nJMTce4xM0l8e9rWHV/ZM8z1Jvo8R4jlBRVU5WnhN5BSYShDALXPCenthBNIVmcvQQQ1j0TgH154yGG0XlrdiRQWJq0iGPKEQG8+cWExt8PwJylM3rTBZkjZidIoVn/SfBBkNrB2Aug== X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55c31237-5da1-4da5-1254-08d86c76a5cc X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2020 17:13:31.9428 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wIrH+nz/bqRtteRt8XjzqJIWDN5CSghEBWEnPqBivvyCnHZKCGeC/B4uD5xVEFn+I5TnqUF9ygGVuvEA20FfAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB3455 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller Smatch complains: drivers/staging/wfx/hif_rx.c:26 hif_generic_confirm() warn: negative user subtract: 0-u16max - 4 20 static int hif_generic_confirm(struct wfx_dev *wdev, 21 const struct hif_msg *hif, const void *buf) 22 { 23 // All confirm messages start with status 24 int status = le32_to_cpup((__le32 *)buf); 25 int cmd = hif->id; 26 int len = le16_to_cpu(hif->len) - 4; // drop header ^^^^^ 27 28 WARN(!mutex_is_locked(&wdev->hif_cmd.lock), "data locking error"); In fact, rx_helper() already make the necessary checks on the value of hif->len. Never mind, add an explicit check to make Smatch happy. Reported-by: Dan Carpenter Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/hif_rx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index ca09467cba05..2d4265257112 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -40,10 +40,10 @@ static int hif_generic_confirm(struct wfx_dev *wdev, } if (wdev->hif_cmd.buf_recv) { - if (wdev->hif_cmd.len_recv >= len) + if (wdev->hif_cmd.len_recv >= len && len > 0) memcpy(wdev->hif_cmd.buf_recv, buf, len); else - status = -ENOMEM; + status = -EIO; } wdev->hif_cmd.ret = status; From patchwork Fri Oct 9 17:13:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 11826921 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5E57C433DF for ; Fri, 9 Oct 2020 17:13:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7421822258 for ; Fri, 9 Oct 2020 17:13:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="fp6G5Ozv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390202AbgJIRN4 (ORCPT ); Fri, 9 Oct 2020 13:13:56 -0400 Received: from mail-eopbgr760074.outbound.protection.outlook.com ([40.107.76.74]:48911 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732603AbgJIRNv (ORCPT ); Fri, 9 Oct 2020 13:13:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BXmiV0YOeM1eeJWAEJ7fD+wGR/P6hGPmZf1g9XofBpd1Hd+OJcnOtkBeBNjsiopkd1Gk8ctg9CqnP/Nlz+GiSc2QIj/yEZ3zwyD405pRdjuRC4qdm4OXrtcFqOEeGw3Q7o3R783bD1dHW09LC4W5JPuJiC9RQyN4uHyUm9pOrm/cv9J02nwHQmIf9jpcvzXdnu/BY+SBigO0d9MY8HKYfRg6kFSkfG5I0JTcx2q0FNeJ0VVk9+FwLUGDmh0DW+AC8z/WTesyMDB9e1dwGoF20tqOqQO5kyuxpWoSCWK5eAttIZoDSATK6KMox5jTHm+py5t/y7T3H50eSQ2Cd5THgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QtasuF9Nudblhbs014fYVVwK2tUkPpLxKPDVvj58WjM=; b=D+EEzCnmoaRjoz3SrG5yxoFPxabH6V9mvbwF3HIrWDWuKXnmwApxPqPAFOp1H6tG+NBqixLkMv0y3NjCQgtyE4JzBeZO3M1HnCxfXCwiyAPsni3BI60BVrHH09qhuPIS0M2TZE8TIrYsQP9bHmGNFvIcRu5WG/jqxXmNv1P87QqMxR/JhYHA9LYMVGEojb5c0bKLuib4son0tMcfPyMmXrtSLn+ODHUz0n0ZrGBJp9zSj8PkrxyyeRtD0ZJ406c+JX6TdKUf9m11aibE+ZvVx2OuqXDYJcIpq1E1X+vHEp30llCy1E6i/pEkwaCuxZv1ngFfXejwfgA6OE8o1Px66g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QtasuF9Nudblhbs014fYVVwK2tUkPpLxKPDVvj58WjM=; b=fp6G5OzvCgpTir0ZHpjTgAZbvQtxw6i9DBrgXlND/78GRd5/oOKUQEPDfaukCAk1pxyFFz7lNIn1mO6N3IRAe5v0bxRgO9nOdkYi/iv8Upms+EInxwcH39niQpHcgqVgd7H2JjtjbAjOMsMB7KLzZfjg63kQgknm2i+4t7dQRlk= Authentication-Results: driverdev.osuosl.org; dkim=none (message not signed) header.d=none;driverdev.osuosl.org; dmarc=none action=none header.from=silabs.com; Received: from SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) by SN6PR11MB3455.namprd11.prod.outlook.com (2603:10b6:805:bb::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.22; Fri, 9 Oct 2020 17:13:34 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a%5]) with mapi id 15.20.3455.024; Fri, 9 Oct 2020 17:13:33 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , Dan Carpenter , =?utf-8?b?SsOpcsO0bWUgUG91aWxs?= =?utf-8?b?ZXI=?= Subject: [PATCH 6/8] staging: wfx: gpiod_get_value() can return an error Date: Fri, 9 Oct 2020 19:13:05 +0200 Message-Id: <20201009171307.864608-7-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201009171307.864608-1-Jerome.Pouiller@silabs.com> References: <20201009171307.864608-1-Jerome.Pouiller@silabs.com> X-Originating-IP: [82.67.86.106] X-ClientProxiedBy: SA9PR10CA0004.namprd10.prod.outlook.com (2603:10b6:806:a7::9) To SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.silabs.com (82.67.86.106) by SA9PR10CA0004.namprd10.prod.outlook.com (2603:10b6:806:a7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24 via Frontend Transport; Fri, 9 Oct 2020 17:13:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6b2fa867-46cd-471e-09eb-08d86c76a6ef X-MS-TrafficTypeDiagnostic: SN6PR11MB3455: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:346; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jo+Hu6pyok/TKJgjq/XfIVcGpFawVDxSbI9hwc3c84kGbw90wO4CoLC1XQ6NBjHv8GB8PtZv9Ip6DXh992FxZUf+zC2ymW1Z8s0lDviTMlZlZN5bK07OulACw4qTSDw/46827NLUhGV/i36OR727+3VXPVL73jTwOxb010vps2boX9lmzZ/ZgLypiinD7mhAjvwWw/hLzhLOf61l0xqD5avB0Zx76nMXrpd0Hhq0Fo9bWFHbhnD9D79Ts1FGUcCfwWFYIAHgBNlVZgpc3ZEs+CErjJkQh/PdMLRKFkG7E6X/AaoT6ZLIliG/Gt6O1FbTZ15gsTYZKM16kuAi2Of3Sg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR11MB2718.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(346002)(376002)(39850400004)(396003)(136003)(8936002)(36756003)(54906003)(1076003)(316002)(52116002)(7696005)(2906002)(5660300002)(478600001)(86362001)(4326008)(66946007)(66556008)(66476007)(6666004)(107886003)(26005)(16526019)(2616005)(83380400001)(186003)(8676002)(956004)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: RQ5LmjiL6egQfY+7k8LxLdW9rBIHeMuPYifzjscuV6/SzmD11q/IK4PL1LhRhup5l/nXTbn1TojXKw+2GkVOdu4HTGdbrxFScBLysV67m8UrzM17T00SnmvCVAtHhKLE+7s5Euh7fgH7TNxCKnpg2cf93nZwg2lEkBp0i33ZMA/Ng64WB4W9s5KgF7ZtWI8J8b7rgCeugVOaqUsCF59GQxCWJzHsKdFskSLoeEPilJs0ZXSQUmUIjVYXfnuAHEdYhDxGg6/BOzztsDQWj6l/M98kwDg4cQ+xOvhxiMX6rf3dr6yY2lBrDy4KhCcFew3Yj6kIgJ6lVjdNkeZe2Ojf+bIfEGcUvUYumL+WX9LqpYG4kXHUhhNmkHp2iWk9Te9E61zaqjFL6UINq3KQeFTmQgW9OtwdzetHlcBLi9xChrC2eg3IxLoG3As1wthf0WdssI4A0vmfYOY/R4BwZh8Sv3AqtH5I5QzHhkSwrYP2ANG0S9eLhd8r+cKr284kzqg9chJPnYuqsoH0aHu5qYwtTDitAnR8U7tE7HYvYsjM2EjuRL53JSQke0OZu7od91fNf1lu2f2I9WtXK35Ztbt1i3QMcXQqjvon9g1dEzbUHfuX4vaPon/+FTuZ6QWY7au7YjyGCi1tR3zHZ+rFIIGhow== X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b2fa867-46cd-471e-09eb-08d86c76a6ef X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2020 17:13:33.8317 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 03danYsUsPm+83G8UUavX00OUuzo6XmDzzzMLhEj4QDp0zTc3XYOs27tR3TxCtx3+krolJM6Lhld8P/bcJES5Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB3455 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller Smatch complains: hif_rx.c:98 hif_wakeup_indication() warn: 'gpiod_get_value(wdev->pdata.gpio_wakeup)' returns positive and negative bh.c:24 device_wakeup() warn: 'gpiod_get_value_cansleep(wdev->pdata.gpio_wakeup)' returns positive and negative Reported-by: Dan Carpenter Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/bh.c | 2 +- drivers/staging/wfx/hif_rx.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c index 586b769c0446..2ffa587aefaa 100644 --- a/drivers/staging/wfx/bh.c +++ b/drivers/staging/wfx/bh.c @@ -21,7 +21,7 @@ static void device_wakeup(struct wfx_dev *wdev) if (!wdev->pdata.gpio_wakeup) return; - if (gpiod_get_value_cansleep(wdev->pdata.gpio_wakeup)) + if (gpiod_get_value_cansleep(wdev->pdata.gpio_wakeup) >= 0) return; if (wfx_api_older_than(wdev, 1, 4)) { diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index 2d4265257112..f99921e76059 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -94,8 +94,8 @@ static int hif_startup_indication(struct wfx_dev *wdev, static int hif_wakeup_indication(struct wfx_dev *wdev, const struct hif_msg *hif, const void *buf) { - if (!wdev->pdata.gpio_wakeup - || !gpiod_get_value(wdev->pdata.gpio_wakeup)) { + if (!wdev->pdata.gpio_wakeup || + gpiod_get_value(wdev->pdata.gpio_wakeup) == 0) { dev_warn(wdev->dev, "unexpected wake-up indication\n"); return -EIO; } From patchwork Fri Oct 9 17:13:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 11826923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E68DC43467 for ; Fri, 9 Oct 2020 17:14:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 157BB22265 for ; Fri, 9 Oct 2020 17:14:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="A7LG23S6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390136AbgJIRNm (ORCPT ); Fri, 9 Oct 2020 13:13:42 -0400 Received: from mail-eopbgr750058.outbound.protection.outlook.com ([40.107.75.58]:34017 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732717AbgJIRNi (ORCPT ); Fri, 9 Oct 2020 13:13:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rwb752P+D9sNjwX2VxL77q9FsS/bY49jD6trhxlb+Ri9s4Z/Ki3h7m4i+U3W/E7s51nDSvTwFhsjSSgDQNkJqLr5hfpmwuAZ352YXFTZYky+CWKZV675b1qcctJzARF78SZTJM/WOS9I1TasdkLdqraQmIO4W34iR2aoSL0lUCgyE/9GAVuyjCl3GBUYm7YEa0xjJkcoR9os6RbB2aHnBdnP9uwhYRnciGDJPJX21IaM4HQwP0ZC5VeIt/kneU4iheTWMJ4MMnP5vtFBdUA4wsEY8E86xLiOV5p49wwvpUXRkxqDXTJehfmT2VA1bJA9HyzTTFTv7S3sdkTRoLQVMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hwlTGiVBkp3Tv0OkYwphI1epijClxbMVwWdCBhhS5IM=; b=ijKOMyeBgEu0m9DsgkucO2GVQEAHow13+eF/L9hYpl9HYH4jsCBGfp5fdj5rT+TBkmXmltsF6SQSH13IW4cniP48bNSe3nFV5pfGdFD5I8wjLDJTKvm/6vKM7s4OYXGlWZFZwKN56h0yvB3p12CsRfqAKBPx82Rryzo7GVemnIvkpVGx7oLMLExLOMTa2hT9XxIffyJA3AiD4aAT8YB1QhV/gLTmZbB9V7J6M/W6HA5bxV/hUZ1Pk+RDz8zWQTXMgfE92QWz0J/Jwcn9G8X9c4XmhIF13AENludyclXtuIMyPs3fICV4yhq3/1eNBjHoV1eeydxO36gnyujy/nM26g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hwlTGiVBkp3Tv0OkYwphI1epijClxbMVwWdCBhhS5IM=; b=A7LG23S61hsjVb0Jbux9RdnJEk0g3imszd6FADAoxnxLjMWV5crxXCewoyjU4enV2Pak3yHqwe9w925lIYVnzT8EHLRCrV/NRZuU0GdudTMHy3Eb8wPdXjrYBH2uF7qZheA7adg4NiqtEVGuntzy0rgfOD90YDmpBR/kcWajd8Y= Authentication-Results: driverdev.osuosl.org; dkim=none (message not signed) header.d=none;driverdev.osuosl.org; dmarc=none action=none header.from=silabs.com; Received: from SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) by SN6PR11MB3087.namprd11.prod.outlook.com (2603:10b6:805:d3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.32; Fri, 9 Oct 2020 17:13:35 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a%5]) with mapi id 15.20.3455.024; Fri, 9 Oct 2020 17:13:35 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , Dan Carpenter , =?utf-8?b?SsOpcsO0bWUgUG91aWxs?= =?utf-8?b?ZXI=?= Subject: [PATCH 7/8] staging: wfx: drop unicode characters from strings Date: Fri, 9 Oct 2020 19:13:06 +0200 Message-Id: <20201009171307.864608-8-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201009171307.864608-1-Jerome.Pouiller@silabs.com> References: <20201009171307.864608-1-Jerome.Pouiller@silabs.com> X-Originating-IP: [82.67.86.106] X-ClientProxiedBy: SA9PR10CA0004.namprd10.prod.outlook.com (2603:10b6:806:a7::9) To SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.silabs.com (82.67.86.106) by SA9PR10CA0004.namprd10.prod.outlook.com (2603:10b6:806:a7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24 via Frontend Transport; Fri, 9 Oct 2020 17:13:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 691305df-fc06-448b-1f97-08d86c76a816 X-MS-TrafficTypeDiagnostic: SN6PR11MB3087: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:813; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 96RoKKSvw6bMrdGOA/NABUuMVc/D036tG2qVt0nlWrTZIQ/Qo5vI7nu8fHBDEP5KqSgAaZxXTyafYJJaljLKLqQmdNqzZjdCFfbPCmm+SmYohhuRXz1uqU38FP37nWchQ7htRma8c3HFv0e0eBE9SnX+VQm1ZyXYXzMg3K961hxAben5R0jkYgMH0nTkcZPnHFD6v5ZL/UTE3K3Oqx+yHq61bVjEQhRX09iq1/Rfy2XvuGbV1qDFuNvB4j8zA7cpPcdnqJb/Y41O78I1PGRHVE/5S1xjsJ9R4ix2lUwNOAdlsB+SYdOeMirl13yR0nUG4p65l9S0KACNH/ZgR6FAuA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR11MB2718.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(39850400004)(136003)(376002)(346002)(366004)(7696005)(1076003)(2616005)(66476007)(36756003)(66556008)(956004)(478600001)(2906002)(6666004)(5660300002)(54906003)(316002)(6486002)(4326008)(86362001)(8676002)(66946007)(8936002)(52116002)(107886003)(66574015)(186003)(26005)(16526019)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: cIGlgG1M5mslDldp+6mMs4SuFIgTKTuVZ+EYg3LLgSPUQSx/ECIOD7HF8n5R1ZRfdv0E/L80rmvcO7+JAFjBNzdlWXPHH1euE3vTKsNDiOtCrINUstNA6lUzFdJv9sKrz3mKhYTDXHJ8lRdRrYjVwQpum4M7uUbvJg0lGEJnvOWWLo8vLFEkN+z15jPP36zaQVgK8g4GZEPP7/BTPOqxUBX43kHHq+QdzBad3jPFUvEN7X6luBbjmrV4bOnHlJTzmRELpCY14ael7KX47bCIWVBYbDygY7DTH2k0fRfKsbP18/VJwfTDYk6HwRi2tksjInDkIcx5u8H0DvYcz9+gtTFVLNdUZ1Lntp99XsT4+ENwaOCDlIgAKEhmplDT9n9UIYZqHeHadN6Al+s8z7VkvIVTQmChTE7vEVHT901cvudp35g5qCLreWfXxPclSZHedKynNMzJxeVlmhYM9SHur2IXuPrHba4McbNalBFE2R79RsGTY/PSklHfQo7mI8Yy/myrr/VQcEnID4OIBXgG42KroFLonh82uu3MY3lM8RMmUZGzP8Sx0ODL3GBac7wk59Y/oK4FUwgNzCWFZShbZhLx4YvlECTA9mU+AZt02yPq6h3438V6xShoay8koos4j+4tuFKxtxFBMgf3DAT0XA== X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 691305df-fc06-448b-1f97-08d86c76a816 X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2020 17:13:35.7496 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fRBtOswuc8J64z9/V8bjh3896boXCc3Z8uvu1OUYOlsmCMielEYjEMZu7P+dt+cQPbubI7BMAZFG/TvreF2Ayg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB3087 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller Smatch complains: hif_rx.c:235 hif_generic_indication() warn: format string contains non-ascii character '\xc2' hif_rx.c:235 hif_generic_indication() warn: format string contains non-ascii character '\xb0' 234 if (!wfx_api_older_than(wdev, 1, 4)) 235 dev_info(wdev->dev, "Rx test ongoing. Temperature: %d°C\n", ^ 236 body->data.rx_stats.current_temp); So, replace the unicode character. Reported-by: Dan Carpenter Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/hif_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index f99921e76059..56a5f891447b 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -246,7 +246,7 @@ static int hif_generic_indication(struct wfx_dev *wdev, mutex_lock(&wdev->rx_stats_lock); // Older firmware send a generic indication beside RxStats if (!wfx_api_older_than(wdev, 1, 4)) - dev_info(wdev->dev, "Rx test ongoing. Temperature: %d°C\n", + dev_info(wdev->dev, "Rx test ongoing. Temperature: %d degrees C\n", body->data.rx_stats.current_temp); memcpy(&wdev->rx_stats, &body->data.rx_stats, sizeof(wdev->rx_stats)); From patchwork Fri Oct 9 17:13:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 11826913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44736C43457 for ; Fri, 9 Oct 2020 17:13:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ECE9522258 for ; Fri, 9 Oct 2020 17:13:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="CiuKDi6R" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390162AbgJIRNp (ORCPT ); Fri, 9 Oct 2020 13:13:45 -0400 Received: from mail-eopbgr750058.outbound.protection.outlook.com ([40.107.75.58]:34017 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732874AbgJIRNn (ORCPT ); Fri, 9 Oct 2020 13:13:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EGVMiVl94j2vVEPE0rHXZT3SfMNjDUvh3aqi8n3zSieryTRxtD/Lf5mYVtb1SxygoY8M/TL1PkI41mjqGUpNESNpk8+ggFeZwjd3fuirXNt3n3o2FvfxcEBYdWlaSEA0Ax1G12PageeKOHJLrinGVXJw0QRIvBpReUWt6XPTPSHVrQyNY7IslJ7zHm3gdTHMt7Cjvy9J12G60fj2wL0TJHELqw9mM1fjr+k++NaxCo26o1Zq1BiHqoZRbgHLl65Rp+Y4luImmHCyergZIIhgDAR4be1YLoYMnwThDqw0k5G0lSyg2P2I5zot3RzIxLaS5KTjWQGfPEDEpaUp6tpmQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H9C+nIAJ1Ffqm1I50uRTHzLfaztPt1wHruwY6oFnFbU=; b=gCizNDo5XlrFE5cZzion8KADijIt/Cd+ZKUoAUv+u6CJF9YTfJQ3ly9LDQlC/fxtahrZan7CpSqTgBLBg6rkU+Qevet+3n2WCbBg8P1p/wg4+Ypzy7fOu67x2BwFS/AYoJr+3AupTa0/j3Z7qDIqgmF8JIxUnfKomDURfOWEg7W4vmruH93j6uEL1Mk+diYrLVXkcixyPhjC+bH96zO2SwP8w4pTenTK/voPUFABr4jFkTx29ImsbhkOreX5Vnhbv3V+/IJcFmGtpsFSIMZ5gAIQY/p24ENiTmRUY5L/fGA7Q7Gi/yInGqzyKgOrA+Gm4qa8W9pVRInkGBANuO4fhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H9C+nIAJ1Ffqm1I50uRTHzLfaztPt1wHruwY6oFnFbU=; b=CiuKDi6Rbtb4mGhXUD6tfzecpNVHaZnReeZCO6JuYOWsb996IBH9A9kkKkmlIWWoiEqE9bzvdcCSXRHF1okCrjQvBXRdi6I/FOFtdL34UGDB5BmwUYvKfuiQo5kQORTYruJwC+odCeEAgEM8xf4l5ZBRISdOQ4L/Qy4TKgRMAEQ= Authentication-Results: driverdev.osuosl.org; dkim=none (message not signed) header.d=none;driverdev.osuosl.org; dmarc=none action=none header.from=silabs.com; Received: from SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) by SN6PR11MB3087.namprd11.prod.outlook.com (2603:10b6:805:d3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.32; Fri, 9 Oct 2020 17:13:37 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a%5]) with mapi id 15.20.3455.024; Fri, 9 Oct 2020 17:13:37 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , Dan Carpenter , =?utf-8?b?SsOpcsO0bWUgUG91aWxs?= =?utf-8?b?ZXI=?= Subject: [PATCH 8/8] staging: wfx: improve robustness of wfx_get_hw_rate() Date: Fri, 9 Oct 2020 19:13:07 +0200 Message-Id: <20201009171307.864608-9-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201009171307.864608-1-Jerome.Pouiller@silabs.com> References: <20201009171307.864608-1-Jerome.Pouiller@silabs.com> X-Originating-IP: [82.67.86.106] X-ClientProxiedBy: SA9PR10CA0004.namprd10.prod.outlook.com (2603:10b6:806:a7::9) To SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.silabs.com (82.67.86.106) by SA9PR10CA0004.namprd10.prod.outlook.com (2603:10b6:806:a7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24 via Frontend Transport; Fri, 9 Oct 2020 17:13:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2b1fcbf6-7a09-401e-3028-08d86c76a948 X-MS-TrafficTypeDiagnostic: SN6PR11MB3087: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:605; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hCzwWUKBOo+OzGc81x211GCOlkiUqy4bb9mX+dN7HA66AiI8BudLbrJwaaCv8/u+xvNYCkRSWI93Mc3fDBJ/x/gkBuVzuBC0TB2BTUsLgQFz9uoe8i/TGy0gcKjOHGKLDnej8Z3p8YWfhNSmKUo6/PcK6dyHVPvDzlPZ/W3Me+ZcTSHsF2oA2N650WFoGjBUgXgECKPWdN6IqADRfPyEMTIaz636UE9egvAAZUbRPeOD1NvCzUSmm12Ntbw4Ujea/xafPChNRDKw3ELpWcrGICqQsPwP6qK2uwdDpxUukBirwzf1uWn2ydEqEPfSAXUB X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR11MB2718.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(39850400004)(136003)(376002)(346002)(366004)(7696005)(1076003)(2616005)(66476007)(36756003)(66556008)(956004)(478600001)(2906002)(6666004)(5660300002)(54906003)(316002)(6486002)(4326008)(86362001)(8676002)(66946007)(8936002)(52116002)(107886003)(186003)(26005)(16526019);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: A9DOVVcnwFEVj6Wt2IkdU5ZywAmdTQOCDrcQTGyo0/xcBdwCv9WFpSLV/FD3HabQoIkL71v8V121V8EciSYoqcXljkE6IYr7VssYaM/U4MPJfAhYLgg+yErTUgkmIsRoLiQMTneClD07DtECs5y3dPuvv/o6A3QtaIKYCXun/PlrlZyadZcBT4GyjsFjq87Pdm/N2ZZbc9i4q2KDTaN8ejDRZ38ZQWmcFeKPsB0yS14DJbHMmrgZx0MD22eiJiXECIoZit99RgDGytEuyW4F6HewHTzbkhWt6AoTLHIPFDIW+XIuvz8jboqpAnOKmoAxu1bnXXZAn9cqunNoavTKseitm3DGifBvt5Zf+gdP9guMMqP83DSxu7/HgcjDesPVKxPCfreue02tlWeEUaG5OIy11YdLEges+YYQOKXelupbrfT7Uw2BYxcntznymkbLeDU8uEIZkn8+y2vIHiOoPRqb4nr23nLObJmo1UEMuCPetcDXegOGhB5HNVbRIB0UtP4rldNpAif0Qc6afhJTtKeA+IeDSsezt+9x2d+4W6w2CEC4Hss9tWxdjFh8LTCKbZkUlAhL4LEiMKVL9UGw7Ajpix3yGAVbtJ4EkJp3RdNQruQCKEoRqY4QlMdajr9Ee2W6Fo3WH8gQ3/sftSaqzw== X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2b1fcbf6-7a09-401e-3028-08d86c76a948 X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2020 17:13:37.7165 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JQ8E02dQnRBJg0JTHjA3zezDx0UH542T1w0y7XZCnEY8stl0JhKxjeAXwur66hoktJlov+yjvFCG9lF8AMmleg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB3087 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller Smatch complains: data_tx.c:37 wfx_get_hw_rate() warn: constraint '(struct ieee80211_supported_band)->bitrates' overflow 'band->bitrates' 0 <= abs_rl '0-127' user_rl '' required = '(struct ieee80211_supported_band)->n_bitrates' 23 struct ieee80211_supported_band *band; 24 25 if (rate->idx < 0) 26 return -1; 27 if (rate->flags & IEEE80211_TX_RC_MCS) { 28 if (rate->idx > 7) { 29 WARN(1, "wrong rate->idx value: %d", rate->idx); 30 return -1; 31 } 32 return rate->idx + 14; 33 } 34 // WFx only support 2GHz, else band information should be retrieved 35 // from ieee80211_tx_info 36 band = wdev->hw->wiphy->bands[NL80211_BAND_2GHZ]; 37 return band->bitrates[rate->idx].hw_value; Add a simple check to make Smatch happy. Reported-by: Dan Carpenter Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/data_tx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index 8db0be08daf8..41f6a604a697 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -31,6 +31,10 @@ static int wfx_get_hw_rate(struct wfx_dev *wdev, } return rate->idx + 14; } + if (rate->idx >= band->n_bitrates) { + WARN(1, "wrong rate->idx value: %d", rate->idx); + return -1; + } // WFx only support 2GHz, else band information should be retrieved // from ieee80211_tx_info band = wdev->hw->wiphy->bands[NL80211_BAND_2GHZ];