From: Sean Anderson <sean.anderson@seco.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
kbuild@lists.01.org,
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
Cc: lkp@intel.com, kbuild-all@lists.01.org,
Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [linux-next:master 2112/3285] drivers/net/phy/phylink.c:588 phylink_validate_mask_caps() warn: variable dereferenced before check 'state' (see line 583)
Date: Mon, 24 Oct 2022 13:13:51 -0400 [thread overview]
Message-ID: <6644de0b-dcab-9a9c-563b-1725090240d2@seco.com> (raw)
In-Reply-To: <202210242228.KXXNz0bU-lkp@intel.com>
On 10/24/22 10:30, Dan Carpenter wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head: 76cf65d1377f733af1e2a55233e3353ffa577f54
> commit: f392a1846489720fc2e063d1210633b6cf4ec5a4 [2112/3285] net: phylink: provide phylink_validate_mask_caps() helper
> config: microblaze-randconfig-m031-20221023
> compiler: microblaze-linux-gcc (GCC) 12.1.0
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@intel.com>
> | Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> New smatch warnings:
> drivers/net/phy/phylink.c:588 phylink_validate_mask_caps() warn: variable dereferenced before check 'state' (see line 583)
>
> Old smatch warnings:
> drivers/net/phy/phylink.c:1104 phylink_change_inband_advert() error: we previously assumed 'pl->pcs' could be null (see line 1087)
>
> vim +/state +588 drivers/net/phy/phylink.c
>
> f392a184648972 Russell King (Oracle 2022-10-17 574) void phylink_validate_mask_caps(unsigned long *supported,
> f392a184648972 Russell King (Oracle 2022-10-17 575) struct phylink_link_state *state,
> f392a184648972 Russell King (Oracle 2022-10-17 576) unsigned long mac_capabilities)
> 34ae2c09d46a2d Russell King (Oracle 2021-11-15 577) {
> 34ae2c09d46a2d Russell King (Oracle 2021-11-15 578) __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
> 3e6eab8f3ef93c Sean Anderson 2022-09-20 579 unsigned long caps;
> 34ae2c09d46a2d Russell King (Oracle 2021-11-15 580)
> 34ae2c09d46a2d Russell King (Oracle 2021-11-15 581) phylink_set_port_modes(mask);
> 34ae2c09d46a2d Russell King (Oracle 2021-11-15 582) phylink_set(mask, Autoneg);
> f392a184648972 Russell King (Oracle 2022-10-17 @583) caps = phylink_get_capabilities(state->interface, mac_capabilities,
> ^^^^^^^^^^^^^^^^
> b7e9294885b610 Sean Anderson 2022-09-20 584 state->rate_matching);
> ^^^^^^^^^^^^^^^^^^^^
> Unchecked dereferences
>
> 3e6eab8f3ef93c Sean Anderson 2022-09-20 585 phylink_caps_to_linkmodes(mask, caps);
> 34ae2c09d46a2d Russell King (Oracle 2021-11-15 586)
> 34ae2c09d46a2d Russell King (Oracle 2021-11-15 587) linkmode_and(supported, supported, mask);
> f392a184648972 Russell King (Oracle 2022-10-17 @588) if (state)
> ^^^^^
> Check for NULL
>
> 34ae2c09d46a2d Russell King (Oracle 2021-11-15 589) linkmode_and(state->advertising, state->advertising, mask);
> 34ae2c09d46a2d Russell King (Oracle 2021-11-15 590) }
>
Hm, looks like I missed this during my conversion, but no existing
codepath depends on this behavior.
Russell, should I send a follow-up fixing this, or do you want to
do that when you submit [1]?
--Sean
[1] http://git.armlinux.org.uk/cgit/linux-arm.git/commit/?h=net-queue&id=ca5662f375de2a44fabcba644a4368c838e1bb22
prev parent reply other threads:[~2022-10-24 17:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-24 14:30 Dan Carpenter
2022-10-24 17:13 ` Sean Anderson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6644de0b-dcab-9a9c-563b-1725090240d2@seco.com \
--to=sean.anderson@seco.com \
--cc=dan.carpenter@oracle.com \
--cc=kbuild-all@lists.01.org \
--cc=kbuild@lists.01.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=rmk+kernel@armlinux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox