* [PATCH] net: bcmgenet: Fix NULL vs IS_ERR() checking
@ 2021-12-11 14:01 Miaoqian Lin
2021-12-12 2:42 ` Joe Perches
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Miaoqian Lin @ 2021-12-11 14:01 UTC (permalink / raw)
Cc: linmq006, Doug Berger, Florian Fainelli, David S. Miller,
Jakub Kicinski, bcm-kernel-feedback-list, netdev, linux-kernel
The phy_attach() function does not return NULL. It returns error pointers.
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
drivers/net/ethernet/broadcom/genet/bcmmii.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
index 5f259641437a..c888ddee1fc4 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
@@ -589,9 +589,9 @@ static int bcmgenet_mii_pd_init(struct bcmgenet_priv *priv)
* Internal or external PHY with MDIO access
*/
phydev = phy_attach(priv->dev, phy_name, pd->phy_interface);
- if (!phydev) {
+ if (IS_ERR(phydev)) {
dev_err(kdev, "failed to register PHY device\n");
- return -ENODEV;
+ return PTR_ERR(phydev);
}
} else {
/*
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: bcmgenet: Fix NULL vs IS_ERR() checking
2021-12-11 14:01 [PATCH] net: bcmgenet: Fix NULL vs IS_ERR() checking Miaoqian Lin
@ 2021-12-12 2:42 ` Joe Perches
2021-12-12 3:58 ` Florian Fainelli
2021-12-13 14:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2021-12-12 2:42 UTC (permalink / raw)
To: Miaoqian Lin, Dan Carpenter
Cc: Doug Berger, Florian Fainelli, David S. Miller, Jakub Kicinski,
bcm-kernel-feedback-list, netdev, linux-kernel
On Sat, 2021-12-11 at 14:01 +0000, Miaoqian Lin wrote:
> The phy_attach() function does not return NULL. It returns error pointers.
Perhaps all the functions that return error pointers rather than
NULL on error should be marked with a special attribute:
Something like:
#define __returns_nonnull __attribute__((__returns_nonnull__))
---
include/linux/compiler_attributes.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h
index 37e2600202216..e2351a36dda97 100644
--- a/include/linux/compiler_attributes.h
+++ b/include/linux/compiler_attributes.h
@@ -250,6 +250,18 @@
# define __no_profile
#endif
+/*
+ * Optional: only supported since GCC >= 5.x
+ *
+ * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#returns-nonnull
+ */
+#if __has_attribute(__returns_nonnull__)
+# define __returns_nonnull __attribute__((__returns_nonnull__))
+#else
+# define __returns_nonnull
+#endif
+
/*
* gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noreturn-function-attribute
* clang: https://clang.llvm.org/docs/AttributeReference.html#noreturn
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: bcmgenet: Fix NULL vs IS_ERR() checking
2021-12-11 14:01 [PATCH] net: bcmgenet: Fix NULL vs IS_ERR() checking Miaoqian Lin
2021-12-12 2:42 ` Joe Perches
@ 2021-12-12 3:58 ` Florian Fainelli
2021-12-13 14:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2021-12-12 3:58 UTC (permalink / raw)
To: Miaoqian Lin
Cc: Doug Berger, Florian Fainelli, David S. Miller, Jakub Kicinski,
bcm-kernel-feedback-list, netdev, linux-kernel
On 12/11/2021 6:01 AM, Miaoqian Lin wrote:
> The phy_attach() function does not return NULL. It returns error pointers.
>
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: bcmgenet: Fix NULL vs IS_ERR() checking
2021-12-11 14:01 [PATCH] net: bcmgenet: Fix NULL vs IS_ERR() checking Miaoqian Lin
2021-12-12 2:42 ` Joe Perches
2021-12-12 3:58 ` Florian Fainelli
@ 2021-12-13 14:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-12-13 14:40 UTC (permalink / raw)
To: =?utf-8?b?5p6X5aaZ5YCpIDxsaW5tcTAwNkBnbWFpbC5jb20+?=
Cc: opendmb, f.fainelli, davem, kuba, bcm-kernel-feedback-list,
netdev, linux-kernel
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:
On Sat, 11 Dec 2021 14:01:53 +0000 you wrote:
> The phy_attach() function does not return NULL. It returns error pointers.
>
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
> drivers/net/ethernet/broadcom/genet/bcmmii.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Here is the summary with links:
- net: bcmgenet: Fix NULL vs IS_ERR() checking
https://git.kernel.org/netdev/net/c/ab8eb798ddab
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-13 14:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-11 14:01 [PATCH] net: bcmgenet: Fix NULL vs IS_ERR() checking Miaoqian Lin
2021-12-12 2:42 ` Joe Perches
2021-12-12 3:58 ` Florian Fainelli
2021-12-13 14:40 ` patchwork-bot+netdevbpf
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.