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: 288696 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?SsOpcsO0bWUgUG91?= =?utf-8?q?iller?= 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;