From: Dan Carpenter <dan.carpenter@oracle.com>
To: "weiyongjun (A)" <weiyongjun1@huawei.com>
Cc: Tobias Waldekranz <tobias@waldekranz.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Andrew Lunn <andrew@lunn.ch>,
Marcin Wojtas <mw@semihalf.com>,
Calvin Johnson <calvin.johnson@oss.nxp.com>,
Markus Koch <markus@notsyncing.net>,
netdev@vger.kernel.org, kernel-janitors@vger.kernel.org,
Hulk Robot <hulkci@huawei.com>
Subject: Re: [PATCH net-next] net/fsl: xgmac_mdio: fix return value check in xgmac_mdio_probe()
Date: Tue, 1 Feb 2022 14:07:11 +0300 [thread overview]
Message-ID: <20220201110711.GR1978@kadam> (raw)
In-Reply-To: <2855194d-9680-c78f-ad87-a2b789cc0363@huawei.com>
On Sun, Jan 30, 2022 at 08:58:55AM +0800, weiyongjun (A) wrote:
>
> > On Sat, Jan 29, 2022 at 01:27, Wei Yongjun <weiyongjun1@huawei.com> wrote:
> > > In case of error, the function devm_ioremap() returns NULL pointer
> > > not ERR_PTR(). The IS_ERR() test in the return value check should
> > > be replaced with NULL test.
> > >
> > > Fixes: 1d14eb15dc2c ("net/fsl: xgmac_mdio: Use managed device resources")
> > > Reported-by: Hulk Robot <hulkci@huawei.com>
> > > Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> > Reviewed-by: Tobias Waldekranz <tobias@waldekranz.com>
> >
> > Sorry about that. I started out by using devm_ioremap_resource, which
> > uses the in-band error signaling, and forgot to match the guard when I
> > changed it.
> >
> > I see that this was reported by your CI, do you mind me asking what it
> > is running in the back-end? At least my version of sparse does not seem
> > to catch this.
>
>
> It was reported by coccinelle with follow script:
>
>
> @@
> expression ret, E;
> @@
> ret = \(devm_ioport_map\|
> devm_ioremap\|
> devm_ioremap_wc\|
> devm_irq_alloc_generic_chip\|
> devm_kasprintf\|
> devm_kcalloc\|
> devm_kmalloc\|
> devm_kmalloc_array\|
> devm_kmemdup\|
> devm_kstrdup\|
> devm_kzalloc\|
> \)(...);
> ... when != ret = E
> (
> - IS_ERR(ret)
> + !ret
> |
> - !IS_ERR(ret)
> + ret
> |
> - PTR_ERR(ret)
> + -ENOMEM
> )
>
>
>
> It seems smatch also can report this.
Yeah. I had this patch in my postponed messages but you beat me to
sending it.
The Smatch check for this requires you to have the cross function
database built. I should update it to remove that requirement for
at least the common functions that you have listed.
regards,
dan carpenter
next prev parent reply other threads:[~2022-02-01 11:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-29 1:27 [PATCH net-next] net/fsl: xgmac_mdio: fix return value check in xgmac_mdio_probe() Wei Yongjun
2022-01-29 16:22 ` Tobias Waldekranz
2022-01-30 0:58 ` weiyongjun (A)
2022-02-01 11:07 ` Dan Carpenter [this message]
2022-01-31 11:40 ` patchwork-bot+netdevbpf
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=20220201110711.GR1978@kadam \
--to=dan.carpenter@oracle.com \
--cc=andrew@lunn.ch \
--cc=calvin.johnson@oss.nxp.com \
--cc=davem@davemloft.net \
--cc=hulkci@huawei.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=markus@notsyncing.net \
--cc=mw@semihalf.com \
--cc=netdev@vger.kernel.org \
--cc=tobias@waldekranz.com \
--cc=weiyongjun1@huawei.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.