diff mbox series

[net-next] net: ethernet: mtk_eth_soc: add missing check for rhashtable_init

Message ID 20240516092427.3897322-1-nichen@iscas.ac.cn (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: ethernet: mtk_eth_soc: add missing check for rhashtable_init | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 920 this patch: 920
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 12 of 12 maintainers
netdev/build_clang success Errors and warnings before: 925 this patch: 925
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: 925 this patch: 925
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
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
netdev/contest success net-next-2024-05-17--00-00 (tests: 1034)

Commit Message

Chen Ni May 16, 2024, 9:24 a.m. UTC
Add check for the return value of rhashtable_init() and return the error
if it fails in order to catch the error.

Fixes: 33fc42de3327 ("net: ethernet: mtk_eth_soc: support creating mac address based offload entries")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
 drivers/net/ethernet/mediatek/mtk_ppe.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Hariprasad Kelam May 16, 2024, 9:56 a.m. UTC | #1
> Add check for the return value of rhashtable_init() and return the error if it
> fails in order to catch the error.
> 
> Fixes: 33fc42de3327 ("net: ethernet: mtk_eth_soc: support creating mac
> address based offload entries")
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
>  drivers/net/ethernet/mediatek/mtk_ppe.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c
> b/drivers/net/ethernet/mediatek/mtk_ppe.c
> index 0acee405a749..f7e5e6e52cdf 100644
> --- a/drivers/net/ethernet/mediatek/mtk_ppe.c
> +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
> @@ -884,12 +884,15 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth,
> void __iomem *base, int index)
>  	struct mtk_ppe *ppe;
>  	u32 foe_flow_size;
>  	void *foe;
> +	int ret;
> 
>  	ppe = devm_kzalloc(dev, sizeof(*ppe), GFP_KERNEL);
>  	if (!ppe)
>  		return NULL;
> 
> -	rhashtable_init(&ppe->l2_flows, &mtk_flow_l2_ht_params);
> +	ret = rhashtable_init(&ppe->l2_flows, &mtk_flow_l2_ht_params);
> +	if (ret)
> +		return NULL;

Instead of returning NULL, return actual error ERR_PTR(ret) and use IS_ERR_OR_NULL API to validate the error

Thanks,
Hariprasad k
> 
>  	/* need to allocate a separate device, since it PPE DMA access is
>  	 * not coherent.
> --
> 2.25.1
>
AngeloGioacchino Del Regno May 16, 2024, 10:10 a.m. UTC | #2
Il 16/05/24 11:24, Chen Ni ha scritto:
> Add check for the return value of rhashtable_init() and return the error
> if it fails in order to catch the error.
> 
> Fixes: 33fc42de3327 ("net: ethernet: mtk_eth_soc: support creating mac address based offload entries")
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
>   drivers/net/ethernet/mediatek/mtk_ppe.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c
> index 0acee405a749..f7e5e6e52cdf 100644
> --- a/drivers/net/ethernet/mediatek/mtk_ppe.c
> +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
> @@ -884,12 +884,15 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base, int index)
>   	struct mtk_ppe *ppe;
>   	u32 foe_flow_size;
>   	void *foe;
> +	int ret;
>   
>   	ppe = devm_kzalloc(dev, sizeof(*ppe), GFP_KERNEL);
>   	if (!ppe)
>   		return NULL;
>   
> -	rhashtable_init(&ppe->l2_flows, &mtk_flow_l2_ht_params);
> +	ret = rhashtable_init(&ppe->l2_flows, &mtk_flow_l2_ht_params);
> +	if (ret)
> +		return NULL;

return PTR_ERR(ret);

..then in mtk_eth_soc.c, you will have to fix the check:
			if (!eth->ppe[i]) {

to IS_ERR_OR_NULL( ... )

Cheers,
Angelo

>   
>   	/* need to allocate a separate device, since it PPE DMA access is
>   	 * not coherent.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c
index 0acee405a749..f7e5e6e52cdf 100644
--- a/drivers/net/ethernet/mediatek/mtk_ppe.c
+++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
@@ -884,12 +884,15 @@  struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base, int index)
 	struct mtk_ppe *ppe;
 	u32 foe_flow_size;
 	void *foe;
+	int ret;
 
 	ppe = devm_kzalloc(dev, sizeof(*ppe), GFP_KERNEL);
 	if (!ppe)
 		return NULL;
 
-	rhashtable_init(&ppe->l2_flows, &mtk_flow_l2_ht_params);
+	ret = rhashtable_init(&ppe->l2_flows, &mtk_flow_l2_ht_params);
+	if (ret)
+		return NULL;
 
 	/* need to allocate a separate device, since it PPE DMA access is
 	 * not coherent.