drivers/net/ethernet/netronome/nfp/devlink_param.c:101 nfp_devlink_param_u8_get() warn: potential spectre issue 'arg->hi_to_dl' (local cap)

From: kernel test robot
Date: Thu Aug 13 2020 - 21:54:37 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: dddcbc139e96bd18d8c65ef7b7e440f0d32457c2
commit: ff04788c5b583d79c5c15e28c4ae7b876e69d00c nfp: devlink: add 'fw_load_policy' support
date: 11 months ago
config: ia64-randconfig-m031-20200811 (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

smatch warnings:
drivers/net/ethernet/netronome/nfp/devlink_param.c:101 nfp_devlink_param_u8_get() warn: potential spectre issue 'arg->hi_to_dl' [r] (local cap)

vim +101 drivers/net/ethernet/netronome/nfp/devlink_param.c

56
57 static int
58 nfp_devlink_param_u8_get(struct devlink *devlink, u32 id,
59 struct devlink_param_gset_ctx *ctx)
60 {
61 const struct nfp_devlink_param_u8_arg *arg;
62 struct nfp_pf *pf = devlink_priv(devlink);
63 struct nfp_nsp *nsp;
64 char hwinfo[32];
65 long value;
66 int err;
67
68 if (id >= ARRAY_SIZE(nfp_devlink_u8_args))
69 return -EOPNOTSUPP;
70
71 arg = &nfp_devlink_u8_args[id];
72
73 nsp = nfp_nsp_open(pf->cpp);
74 if (IS_ERR(nsp)) {
75 err = PTR_ERR(nsp);
76 nfp_warn(pf->cpp, "can't access NSP: %d\n", err);
77 return err;
78 }
79
80 snprintf(hwinfo, sizeof(hwinfo), arg->hwinfo_name);
81 err = nfp_nsp_hwinfo_lookup_optional(nsp, hwinfo, sizeof(hwinfo),
82 arg->default_hi_val);
83 if (err) {
84 nfp_warn(pf->cpp, "HWinfo lookup failed: %d\n", err);
85 goto exit_close_nsp;
86 }
87
88 err = kstrtol(hwinfo, 0, &value);
89 if (err || value < 0 || value > arg->max_hi_val) {
90 nfp_warn(pf->cpp, "HWinfo '%s' value %li invalid\n",
91 arg->hwinfo_name, value);
92
93 if (arg->invalid_dl_val >= 0)
94 ctx->val.vu8 = arg->invalid_dl_val;
95 else
96 err = arg->invalid_dl_val;
97
98 goto exit_close_nsp;
99 }
100
> 101 ctx->val.vu8 = arg->hi_to_dl[value];
102
103 exit_close_nsp:
104 nfp_nsp_close(nsp);
105 return err;
106 }
107

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip