lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 4 Jan 2022 17:43:52 +0900
From:   Hector Martin <marcan@...can.st>
To:     Dmitry Osipenko <digetx@...il.com>,
        Kalle Valo <kvalo@...eaurora.org>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Rob Herring <robh+dt@...nel.org>,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        Len Brown <lenb@...nel.org>,
        Arend van Spriel <aspriel@...il.com>,
        Franky Lin <franky.lin@...adcom.com>,
        Hante Meuleman <hante.meuleman@...adcom.com>,
        Chi-hsien Lin <chi-hsien.lin@...ineon.com>,
        Wright Feng <wright.feng@...ineon.com>
Cc:     Sven Peter <sven@...npeter.dev>,
        Alyssa Rosenzweig <alyssa@...enzweig.io>,
        Mark Kettenis <kettenis@...nbsd.org>,
        Rafał Miłecki <zajec5@...il.com>,
        Pieter-Paul Giesberts <pieter-paul.giesberts@...adcom.com>,
        Linus Walleij <linus.walleij@...aro.org>,
        Hans de Goede <hdegoede@...hat.com>,
        "John W. Linville" <linville@...driver.com>,
        "brian m. carlson" <sandals@...stytoothpaste.net>,
        Andy Shevchenko <andy.shevchenko@...il.com>,
        linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
        devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-acpi@...r.kernel.org, brcm80211-dev-list.pdl@...adcom.com,
        SHA-cyfmac-dev-list@...ineon.com
Subject: Re: [PATCH v2 04/35] brcmfmac: firmware: Support having multiple alt
 paths

On 2022/01/04 17:26, Dmitry Osipenko wrote:
> 04.01.2022 10:26, Hector Martin пишет:
>> Apple platforms have firmware and config files identified with multiple
>> dimensions. We want to be able to find the most specific firmware
>> available for any given platform, progressively trying more general
>> firmwares.
>>
>> First, add support for having multiple alternate firmware paths.
>>
>> Acked-by: Linus Walleij <linus.walleij@...aro.org>
>> Signed-off-by: Hector Martin <marcan@...can.st>
>> ---
>>  .../broadcom/brcm80211/brcmfmac/firmware.c    | 75 ++++++++++++++-----
>>  .../broadcom/brcm80211/brcmfmac/firmware.h    |  2 +
>>  2 files changed, 59 insertions(+), 18 deletions(-)
>>
>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
>> index 0497b721136a..7570dbf22cdd 100644
>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
>> @@ -427,6 +427,8 @@ void brcmf_fw_nvram_free(void *nvram)
>>  struct brcmf_fw {
>>  	struct device *dev;
>>  	struct brcmf_fw_request *req;
>> +	const char *alt_paths[BRCMF_FW_MAX_ALT_PATHS];
>> +	int alt_index;
> 
> unsigned int

Ack.

> 
>>  	u32 curpos;
>>  	void (*done)(struct device *dev, int err, struct brcmf_fw_request *req);
>>  };
>> @@ -592,14 +594,18 @@ static int brcmf_fw_complete_request(const struct firmware *fw,
>>  	return (cur->flags & BRCMF_FW_REQF_OPTIONAL) ? 0 : ret;
>>  }
>>  
>> -static char *brcm_alt_fw_path(const char *path, const char *board_type)
>> +static int brcm_alt_fw_paths(const char *path, const char *board_type,
>> +			     const char *alt_paths[BRCMF_FW_MAX_ALT_PATHS])>  {
>>  	char alt_path[BRCMF_FW_NAME_LEN];
>>  	const char *suffix;
>>  
>> +	memset(alt_paths, 0, array_size(sizeof(*alt_paths),
>> +					BRCMF_FW_MAX_ALT_PATHS));
> You don't need to use array_size() since size of a fixed array is
> already known.
> 
> memset(alt_paths, 0, sizeof(alt_paths));

It's a function argument, so that doesn't work and actually throws a
warning. Array function argument notation is informative only; they
behave strictly equivalent to pointers. Try it:

$ cat test.c
#include <stdio.h>

void foo(char x[42])
{
	printf("%ld\n", sizeof(x));
}

int main() {
	char x[42];

	foo(x);
}
$ gcc test.c
test.c: In function ‘foo’:
test.c:5:31: warning: ‘sizeof’ on array function parameter ‘x’ will
return size of ‘char *’ [-Wsizeof-array-argument]
    5 |         printf("%ld\n", sizeof(x));
      |                               ^
test.c:3:15: note: declared here
    3 | void foo(char x[42])
      |          ~~~~~^~~~~
$ ./a.out
8


> 
> ...
>> +static void
>> +brcm_free_alt_fw_paths(const char *alt_paths[BRCMF_FW_MAX_ALT_PATHS])
>> +{
>> +	unsigned int i;
>> +
>> +	for (i = 0; alt_paths[i]; i++)
> 
> What if array is fully populated and there is no null in the end? Please
> don't do this, use BRCMF_FW_MAX_ALT_PATHS or ARRAY_SIZE().

Argh, forgot to change this one. I used BRCMF_FW_MAX_ALT_PATHS
elsewhere; ARRAY_SIZE won't work as I explained above.

> 
>> +		kfree(alt_paths[i]);
>>  }
>>  
>>  static int brcmf_fw_request_firmware(const struct firmware **fw,
>> @@ -617,19 +634,25 @@ static int brcmf_fw_request_firmware(const struct firmware **fw,
>>  {
>>  	struct brcmf_fw_item *cur = &fwctx->req->items[fwctx->curpos];
>>  	int ret;
>> +	unsigned int i;
> 
> Keep reverse Xmas tree coding style.

First time I hear this one, heh. Sure.

> 
> ...
>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
>> @@ -11,6 +11,8 @@
>>  
>>  #define BRCMF_FW_DEFAULT_PATH		"brcm/"
>>  
>> +#define BRCMF_FW_MAX_ALT_PATHS	8
> 
> Two tabs are needed here.

Will do.

-- 
Hector Martin (marcan@...can.st)
Public Key: https://mrcn.st/pub

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ