Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

octeontx2: don't mess with ->d_parent or ->d_parent->d_name

use debugfs_{create_file,get}_aux_num() instead.

[and for fsck sake, don't call variables filp - especially the
ones that are not even struct file *]

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/r/20250112080705.141166-19-viro@zeniv.linux.org.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Al Viro and committed by
Greg Kroah-Hartman
f526ca6b f22fa721

+24 -52
+24 -52
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
··· 917 917 /* The 'qsize' entry dumps current Aura/Pool context Qsize 918 918 * and each context's current enable/disable status in a bitmap. 919 919 */ 920 - static int rvu_dbg_qsize_display(struct seq_file *filp, void *unsused, 920 + static int rvu_dbg_qsize_display(struct seq_file *s, void *unsused, 921 921 int blktype) 922 922 { 923 - void (*print_qsize)(struct seq_file *filp, 923 + void (*print_qsize)(struct seq_file *s, 924 924 struct rvu_pfvf *pfvf) = NULL; 925 - struct dentry *current_dir; 926 925 struct rvu_pfvf *pfvf; 927 926 struct rvu *rvu; 928 927 int qsize_id; 929 928 u16 pcifunc; 930 929 int blkaddr; 931 930 932 - rvu = filp->private; 931 + rvu = s->private; 933 932 switch (blktype) { 934 933 case BLKTYPE_NPA: 935 934 qsize_id = rvu->rvu_dbg.npa_qsize_id; ··· 944 945 return -EINVAL; 945 946 } 946 947 947 - if (blktype == BLKTYPE_NPA) { 948 + if (blktype == BLKTYPE_NPA) 948 949 blkaddr = BLKADDR_NPA; 949 - } else { 950 - current_dir = filp->file->f_path.dentry->d_parent; 951 - blkaddr = (!strcmp(current_dir->d_name.name, "nix1") ? 952 - BLKADDR_NIX1 : BLKADDR_NIX0); 953 - } 950 + else 951 + blkaddr = debugfs_get_aux_num(s->file); 954 952 955 953 if (!rvu_dbg_is_valid_lf(rvu, blkaddr, qsize_id, &pcifunc)) 956 954 return -EINVAL; 957 955 958 956 pfvf = rvu_get_pfvf(rvu, pcifunc); 959 - print_qsize(filp, pfvf); 957 + print_qsize(s, pfvf); 960 958 961 959 return 0; 962 960 } 963 961 964 - static ssize_t rvu_dbg_qsize_write(struct file *filp, 962 + static ssize_t rvu_dbg_qsize_write(struct file *file, 965 963 const char __user *buffer, size_t count, 966 964 loff_t *ppos, int blktype) 967 965 { 968 966 char *blk_string = (blktype == BLKTYPE_NPA) ? "npa" : "nix"; 969 - struct seq_file *seqfile = filp->private_data; 967 + struct seq_file *seqfile = file->private_data; 970 968 char *cmd_buf, *cmd_buf_tmp, *subtoken; 971 969 struct rvu *rvu = seqfile->private; 972 - struct dentry *current_dir; 973 970 int blkaddr; 974 971 u16 pcifunc; 975 972 int ret, lf; ··· 991 996 goto qsize_write_done; 992 997 } 993 998 994 - if (blktype == BLKTYPE_NPA) { 999 + if (blktype == BLKTYPE_NPA) 995 1000 blkaddr = BLKADDR_NPA; 996 - } else { 997 - current_dir = filp->f_path.dentry->d_parent; 998 - blkaddr = (!strcmp(current_dir->d_name.name, "nix1") ? 999 - BLKADDR_NIX1 : BLKADDR_NIX0); 1000 - } 1001 + else 1002 + blkaddr = debugfs_get_aux_num(file); 1001 1003 1002 1004 if (!rvu_dbg_is_valid_lf(rvu, blkaddr, lf, &pcifunc)) { 1003 1005 ret = -EINVAL; ··· 2696 2704 &rvu_dbg_nix_ndc_tx_hits_miss_fops); 2697 2705 debugfs_create_file("ndc_rx_hits_miss", 0600, rvu->rvu_dbg.nix, nix_hw, 2698 2706 &rvu_dbg_nix_ndc_rx_hits_miss_fops); 2699 - debugfs_create_file("qsize", 0600, rvu->rvu_dbg.nix, rvu, 2700 - &rvu_dbg_nix_qsize_fops); 2707 + debugfs_create_file_aux_num("qsize", 0600, rvu->rvu_dbg.nix, rvu, 2708 + blkaddr, &rvu_dbg_nix_qsize_fops); 2701 2709 debugfs_create_file("ingress_policer_ctx", 0600, rvu->rvu_dbg.nix, nix_hw, 2702 2710 &rvu_dbg_nix_band_prof_ctx_fops); 2703 2711 debugfs_create_file("ingress_policer_rsrc", 0600, rvu->rvu_dbg.nix, nix_hw, ··· 2846 2854 return err; 2847 2855 } 2848 2856 2849 - static int rvu_dbg_derive_lmacid(struct seq_file *filp, int *lmac_id) 2857 + static int rvu_dbg_derive_lmacid(struct seq_file *s) 2850 2858 { 2851 - struct dentry *current_dir; 2852 - char *buf; 2853 - 2854 - current_dir = filp->file->f_path.dentry->d_parent; 2855 - buf = strrchr(current_dir->d_name.name, 'c'); 2856 - if (!buf) 2857 - return -EINVAL; 2858 - 2859 - return kstrtoint(buf + 1, 10, lmac_id); 2859 + return debugfs_get_aux_num(s->file); 2860 2860 } 2861 2861 2862 - static int rvu_dbg_cgx_stat_display(struct seq_file *filp, void *unused) 2862 + static int rvu_dbg_cgx_stat_display(struct seq_file *s, void *unused) 2863 2863 { 2864 - int lmac_id, err; 2865 - 2866 - err = rvu_dbg_derive_lmacid(filp, &lmac_id); 2867 - if (!err) 2868 - return cgx_print_stats(filp, lmac_id); 2869 - 2870 - return err; 2864 + return cgx_print_stats(s, rvu_dbg_derive_lmacid(s)); 2871 2865 } 2872 2866 2873 2867 RVU_DEBUG_SEQ_FOPS(cgx_stat, cgx_stat_display, NULL); ··· 2911 2933 return 0; 2912 2934 } 2913 2935 2914 - static int rvu_dbg_cgx_dmac_flt_display(struct seq_file *filp, void *unused) 2936 + static int rvu_dbg_cgx_dmac_flt_display(struct seq_file *s, void *unused) 2915 2937 { 2916 - int err, lmac_id; 2917 - 2918 - err = rvu_dbg_derive_lmacid(filp, &lmac_id); 2919 - if (!err) 2920 - return cgx_print_dmac_flt(filp, lmac_id); 2921 - 2922 - return err; 2938 + return cgx_print_dmac_flt(s, rvu_dbg_derive_lmacid(s)); 2923 2939 } 2924 2940 2925 2941 RVU_DEBUG_SEQ_FOPS(cgx_dmac_flt, cgx_dmac_flt_display, NULL); ··· 2952 2980 rvu->rvu_dbg.lmac = 2953 2981 debugfs_create_dir(dname, rvu->rvu_dbg.cgx); 2954 2982 2955 - debugfs_create_file("stats", 0600, rvu->rvu_dbg.lmac, 2956 - cgx, &rvu_dbg_cgx_stat_fops); 2957 - debugfs_create_file("mac_filter", 0600, 2958 - rvu->rvu_dbg.lmac, cgx, 2983 + debugfs_create_file_aux_num("stats", 0600, rvu->rvu_dbg.lmac, 2984 + cgx, lmac_id, &rvu_dbg_cgx_stat_fops); 2985 + debugfs_create_file_aux_num("mac_filter", 0600, 2986 + rvu->rvu_dbg.lmac, cgx, lmac_id, 2959 2987 &rvu_dbg_cgx_dmac_flt_fops); 2960 2988 } 2961 2989 }