diff mbox series

[net] dpll: fix build failure due to rcu_dereference_check() on unknown type

Message ID 20240229190515.2740221-1-kuba@kernel.org (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series [net] dpll: fix build failure due to rcu_dereference_check() on unknown type | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 958 this patch: 958
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 974 this patch: 974
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 975 this patch: 975
netdev/checkpatch warning WARNING: please, no spaces at the start of a line
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jakub Kicinski Feb. 29, 2024, 7:05 p.m. UTC
From: Eric Dumazet <edumazet@google.com>

Tasmiya reports that their compiler complains that we deref
a pointer to unknown type with rcu_dereference_rtnl():

include/linux/rcupdate.h:439:9: error: dereferencing pointer to incomplete type ‘struct dpll_pin’

Unclear what compiler it is, at the moment, and we can't report
but since DPLL can't be a module - move the code from the header
into the source file.

Fixes: 0d60d8df6f49 ("dpll: rely on rcu for netdev_dpll_pin()")
Reported-by: Tasmiya Nalatwad <tasmiya@linux.vnet.ibm.com>
Link: https://lore.kernel.org/all/3fcf3a2c-1c1b-42c1-bacb-78fdcd700389@linux.vnet.ibm.com/
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
Sending officially the solution Eric suggested in the report
thread. The bug is pending in the net tree, so I'd like to
put this on an express path, to make today's PR...

CC: vadim.fedorenko@linux.dev
CC: arkadiusz.kubalewski@intel.com
CC: jiri@resnulli.us
---
 drivers/dpll/dpll_core.c | 5 +++++
 include/linux/dpll.h     | 8 ++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

Comments

Vadim Fedorenko Feb. 29, 2024, 8:42 p.m. UTC | #1
On 29/02/2024 19:05, Jakub Kicinski wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> Tasmiya reports that their compiler complains that we deref
> a pointer to unknown type with rcu_dereference_rtnl():
> 
> include/linux/rcupdate.h:439:9: error: dereferencing pointer to incomplete type ‘struct dpll_pin’
> 
> Unclear what compiler it is, at the moment, and we can't report
> but since DPLL can't be a module - move the code from the header
> into the source file.
> 
> Fixes: 0d60d8df6f49 ("dpll: rely on rcu for netdev_dpll_pin()")
> Reported-by: Tasmiya Nalatwad <tasmiya@linux.vnet.ibm.com>
> Link: https://lore.kernel.org/all/3fcf3a2c-1c1b-42c1-bacb-78fdcd700389@linux.vnet.ibm.com/
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> Sending officially the solution Eric suggested in the report
> thread. The bug is pending in the net tree, so I'd like to
> put this on an express path, to make today's PR...
> 
> CC: vadim.fedorenko@linux.dev
> CC: arkadiusz.kubalewski@intel.com
> CC: jiri@resnulli.us
> ---
>   drivers/dpll/dpll_core.c | 5 +++++
>   include/linux/dpll.h     | 8 ++++----
>   2 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
> index 4c2bb27c99fe..507dd9cfb075 100644
> --- a/drivers/dpll/dpll_core.c
> +++ b/drivers/dpll/dpll_core.c
> @@ -42,6 +42,11 @@ struct dpll_pin_registration {
>   	void *priv;
>   };
>   
> +struct dpll_pin *netdev_dpll_pin(const struct net_device *dev)
> +{
> +       return rcu_dereference_rtnl(dev->dpll_pin);
> +}
> +
>   struct dpll_device *dpll_device_get_by_id(int id)
>   {
>   	if (xa_get_mark(&dpll_device_xa, id, DPLL_REGISTERED))
> diff --git a/include/linux/dpll.h b/include/linux/dpll.h
> index 4ec2fe9caf5a..c60591308ae8 100644
> --- a/include/linux/dpll.h
> +++ b/include/linux/dpll.h
> @@ -169,13 +169,13 @@ int dpll_device_change_ntf(struct dpll_device *dpll);
>   
>   int dpll_pin_change_ntf(struct dpll_pin *pin);
>   
> +#if !IS_ENABLED(CONFIG_DPLL)
>   static inline struct dpll_pin *netdev_dpll_pin(const struct net_device *dev)
>   {
> -#if IS_ENABLED(CONFIG_DPLL)
> -	return rcu_dereference_rtnl(dev->dpll_pin);
> -#else
>   	return NULL;
> -#endif
>   }
> +#else
> +struct dpll_pin *netdev_dpll_pin(const struct net_device *dev);
> +#endif
>   
>   #endif

That also works (as well as void *),

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Jakub Kicinski Feb. 29, 2024, 9:10 p.m. UTC | #2
On Thu, 29 Feb 2024 11:05:15 -0800 Jakub Kicinski wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> Tasmiya reports that their compiler complains that we deref
> a pointer to unknown type with rcu_dereference_rtnl():
> 
> include/linux/rcupdate.h:439:9: error: dereferencing pointer to incomplete type ‘struct dpll_pin’
> 
> Unclear what compiler it is, at the moment, and we can't report
> but since DPLL can't be a module - move the code from the header
> into the source file.

Applied, and pushed for the PR..
diff mbox series

Patch

diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 4c2bb27c99fe..507dd9cfb075 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -42,6 +42,11 @@  struct dpll_pin_registration {
 	void *priv;
 };
 
+struct dpll_pin *netdev_dpll_pin(const struct net_device *dev)
+{
+       return rcu_dereference_rtnl(dev->dpll_pin);
+}
+
 struct dpll_device *dpll_device_get_by_id(int id)
 {
 	if (xa_get_mark(&dpll_device_xa, id, DPLL_REGISTERED))
diff --git a/include/linux/dpll.h b/include/linux/dpll.h
index 4ec2fe9caf5a..c60591308ae8 100644
--- a/include/linux/dpll.h
+++ b/include/linux/dpll.h
@@ -169,13 +169,13 @@  int dpll_device_change_ntf(struct dpll_device *dpll);
 
 int dpll_pin_change_ntf(struct dpll_pin *pin);
 
+#if !IS_ENABLED(CONFIG_DPLL)
 static inline struct dpll_pin *netdev_dpll_pin(const struct net_device *dev)
 {
-#if IS_ENABLED(CONFIG_DPLL)
-	return rcu_dereference_rtnl(dev->dpll_pin);
-#else
 	return NULL;
-#endif
 }
+#else
+struct dpll_pin *netdev_dpll_pin(const struct net_device *dev);
+#endif
 
 #endif