Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1239584pxb; Fri, 21 Jan 2022 13:06:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6Q+XMW8C3InQoDXTXAeRIKqRrWcSHbg64KaEGSxquzRiNFnnHIjsqmKzVm8d/uVbv2eJa X-Received: by 2002:aa7:904e:0:b0:4bc:bdd5:f3d with SMTP id n14-20020aa7904e000000b004bcbdd50f3dmr5284016pfo.9.1642799197164; Fri, 21 Jan 2022 13:06:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642799197; cv=none; d=google.com; s=arc-20160816; b=F2diElYWedFh3ALACXsInx78NTAnu79jrEkyhmrDT8hVEcVPNhhJfpunsOm8FF8TpX 33kBOeVJpCDcqu/ZlHBpYXdsqW+ZBvDuw9DpjPZJLdwGr01nBJkdeK3xLs/1cxexP6fg RC3lvmhP6BJEjHosG+A6ki4rkCGy2zcFffGDzM4p4VIw3Sj5ciDvrAZjcERIUUVYHIU2 vvoBMjq/wWFmYgQIrNaJahLXkvloyu34KY8NVTP1qDq7mNhsGK7AjhDXMz8tNABru/F8 mMXpErDEhBmAnmU8M++ps0qbXgdt9hmlWq2aZGI9JdAQv7M+qikbZNIf1k7onxcIFsmM rK8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=+TtTpdW2XXcN7PJshZWrMf1q9DFDrKk/YTAEqvNRxI4=; b=Zj21s85H/SXWHOu79jHLTIcdjUfrHLKAMktjxh7Tjm8bFAkquB6zp3RzjqZM4lt8S2 gSA1/pqDcLYNr+fzrtUkOCRD5vNoYet4wmQPjOJ1hJv74GL7+iCaaU/nx0hyex8VR/uh KBHWJ7hDvv96jigpl6NhRmduXNhkxz4XHLQ4qhz9x106rzRHZ4xupJ3Xpsbr6qwXs+52 X39MJtKMCVGqyxOWVyT0QOFtiEAEdppW9HUqnN+qdnWlc9F8d/13yJw8y0qJNXw6GjgJ lgKkrIbLIHAnNlJrTyOf7gqxI9YiDn/Pv3IQeL1el+so1a8iT85HIa6cGoTR0oH/u/V2 ZIqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=marcan.st Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u9si6703565plz.374.2022.01.21.13.06.24; Fri, 21 Jan 2022 13:06:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=marcan.st Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358677AbiATGNX (ORCPT + 99 others); Thu, 20 Jan 2022 01:13:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbiATGNW (ORCPT ); Thu, 20 Jan 2022 01:13:22 -0500 Received: from mail.marcansoft.com (marcansoft.com [IPv6:2a01:298:fe:f::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82BBAC061574; Wed, 19 Jan 2022 22:13:22 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: marcan@marcan.st) by mail.marcansoft.com (Postfix) with ESMTPSA id E5C2F4246A; Thu, 20 Jan 2022 06:13:13 +0000 (UTC) Subject: Re: [PATCH v3 3/9] brcmfmac: firmware: Do not crash on a NULL board_type To: Andy Shevchenko Cc: Kalle Valo , "David S. Miller" , Jakub Kicinski , Rob Herring , "Rafael J. Wysocki" , Len Brown , Arend van Spriel , Franky Lin , Hante Meuleman , Chi-hsien Lin , Wright Feng , Dmitry Osipenko , Sven Peter , Alyssa Rosenzweig , Mark Kettenis , =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= , Pieter-Paul Giesberts , Linus Walleij , Hans de Goede , "John W. Linville" , "brian m. carlson" , "open list:TI WILINK WIRELES..." , netdev , devicetree , Linux Kernel Mailing List , ACPI Devel Maling List , "open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER" , SHA-cyfmac-dev-list@infineon.com References: <20220117142919.207370-1-marcan@marcan.st> <20220117142919.207370-4-marcan@marcan.st> From: Hector Martin Message-ID: Date: Thu, 20 Jan 2022 15:13:11 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: es-ES Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20/01/2022 06.45, Andy Shevchenko wrote: > On Mon, Jan 17, 2022 at 4:30 PM Hector Martin wrote: >> >> This unbreaks support for USB devices, which do not have a board_type >> to create an alt_path out of and thus were running into a NULL >> dereference. > > In v5.16 we have two call sites: > > 1. > if (cur->type == BRCMF_FW_TYPE_NVRAM && fwctx->req->board_type) { > ... > alt_path = brcm_alt_fw_path(cur->path, fwctx->req->board_type); > > 2. > alt_path = brcm_alt_fw_path(first->path, fwctx->req->board_type); > if (alt_path) { > ... > > Looking at them I would rather expect to see (as a quick fix, the > better solution is to unify those call sites by splitting out a common > helper): > > if (fwctx->req->board_type) { > alt_path = brcm_alt_fw_path(first->path, fwctx->req->board_type); > else > alt_path = NULL; > ... > Since brcm_alt_fw_path can fail anyway, and its return value is already NULL-checked, it makes sense to propagate the NULL board_path there rather than doing it at all the callsites. That's a common pattern, e.g. the entire DT API is designed to accept NULL nodes. That does mean that the first callsite has a redundant NULL check, yes, but that doesn't hurt. This is all going to change with subsequent patches anyway; the point of this patch is just to fix the regression. -- Hector Martin (marcan@marcan.st) Public Key: https://mrcn.st/pub