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:   Thu, 13 Oct 2022 09:33:29 +0200
From:   "Arnd Bergmann" <arnd@...db.de>
To:     "Damien Le Moal" <damien.lemoal@...nsource.wdc.com>,
        "Thomas Bogendoerfer" <tsbogend@...ha.franken.de>,
        linux-mips@...r.kernel.org
Cc:     llvm@...ts.linux.dev, kbuild-all@...ts.01.org,
        linux-kernel@...r.kernel.org
Subject: Re: drivers/ata/ahci_st.c:229:34: warning: unused variable 'st_ahci_match'

On Thu, Oct 13, 2022, at 8:13 AM, Damien Le Moal wrote:
> On 10/12/22 15:37, kernel test robot wrote:

> I am at a loss with this one... There are plenty of patterns similar to
> drivers/ata/ahci_st.c doing something like:
>
> static const struct of_device_id st_ahci_match[] = {
>
>         { .compatible = "st,ahci", },
>
>         { /* sentinel */ }
>
> };
>
> MODULE_DEVICE_TABLE(of, st_ahci_match);
>
> For instance, in drivers/pwm/pwm-sti.c, we have:
>
>
> And countless others like this for STI and other arch too.
>
> So if CONFIG_MODULE is not enabled, how come we are not submerged with
> warnings about unused variables ? Is mips arch special in this regard ?
> Or am I missing something ?

It has nothing to do with MIPS, the problem is

                .of_match_table = of_match_ptr(st_ahci_match),

The 'of_match_ptr()' sets the pointer to NULL when CONFIG_OF is
disabled, which avoids a build failure when st_ahci_match[]
itself is in an #ifdef.

In this driver, there is no #ifdef around st_ahci_match[], so we
simply want

                .of_match_table = st_ahci_match,

The thing with the MODULE_DEVICE_TABLE() is that it would
create another reference if CONFIG_MODULE is enabled, but not
for a built-in driver, so you only get this type of warning
for randconfig builds that have the driver built-in and OF
disabled.

It's a common mistake, and we should probably remove most
of the of_match_ptr() references as you rarely have drivers
that optionally use OF support but benefit from compiling
that support out on kernels without OF.

     Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ