Message ID | 20220419015832.2562366-1-lv.ruyi@zte.com.cn (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | net: ethernet: mtk_eth_soc: fix error check return value of debugfs_create_dir() | expand |
On Tue, Apr 19, 2022 at 01:58:32AM +0000, cgel.zte@gmail.com wrote: > From: Lv Ruyi <lv.ruyi@zte.com.cn> > > If an error occurs, debugfs_create_file() will return ERR_PTR(-ERROR), > so use IS_ERR() to check it. Please take a look at for example: https://lkml.iu.edu/hypermail/linux/kernel/1901.2/06005.html https://lkml.iu.edu/hypermail/linux/kernel/1901.2/06006.html https://lkml.iu.edu/hypermail/linux/kernel/1901.2/05993.html This is the author of debugfs remove exactly the sort of code you are adding. Please teach the Zeal Bot that such code is wrong, and you should be submitting patches to actually remove testing the return values for anything which starts with debugfs_ Andrew
diff --git a/drivers/net/ethernet/mediatek/mtk_wed_debugfs.c b/drivers/net/ethernet/mediatek/mtk_wed_debugfs.c index a81d3fd1a439..0c284c18a8d7 100644 --- a/drivers/net/ethernet/mediatek/mtk_wed_debugfs.c +++ b/drivers/net/ethernet/mediatek/mtk_wed_debugfs.c @@ -165,7 +165,7 @@ void mtk_wed_hw_add_debugfs(struct mtk_wed_hw *hw) snprintf(hw->dirname, sizeof(hw->dirname), "wed%d", hw->index); dir = debugfs_create_dir(hw->dirname, NULL); - if (!dir) + if (IS_ERR(dir)) return; hw->debugfs_dir = dir;