net/ethtool/module.c:186 ethnl_module_fw_flash_ntf_put_err() warn: passing zero to 'PTR_ERR'
PATCH 30/41 net/ethtool/module.c:186 ethnl_module_fw_flash_ntf_put_err() warn: passing zero to 'PTR_ERR'
tree: https://github.com/jpirko/linux_mlxsw combined_queue head: ded71079fd9b5d39c76a01fdfa82eb29e047b512 commit: c270a7d3889b3655d39165331365c2c65d41185f [30/41] ethtool: Add flashing transceiver modules' firmware notifications ability config: i386-randconfig-141-20240620 (https://download.01.org/0day-ci/archive/20240620/[email protected]/config) compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
smatch warnings:net/ethtool/module.c:186 ethnl_module_fw_flash_ntf_put_err() warn: passing zero to 'PTR_ERR'
vim +/PTR_ERR +186 net/ethtool/module.c
c270a7d3889b36 Danielle Ratson 2024-06-17 165 static int
c270a7d3889b36 Danielle Ratson 2024-06-17 166 ethnl_module_fw_flash_ntf_put_err(struct sk_buff *skb, char *err_msg,
c270a7d3889b36 Danielle Ratson 2024-06-17 167 char *sub_err_msg)
c270a7d3889b36 Danielle Ratson 2024-06-17 168 {
c270a7d3889b36 Danielle Ratson 2024-06-17 169 int err_msg_len, sub_err_msg_len, total_len;
c270a7d3889b36 Danielle Ratson 2024-06-17 170 struct nlattr *attr;
c270a7d3889b36 Danielle Ratson 2024-06-17 171
c270a7d3889b36 Danielle Ratson 2024-06-17 172 if (!err_msg)
c270a7d3889b36 Danielle Ratson 2024-06-17 173 return 0;
c270a7d3889b36 Danielle Ratson 2024-06-17 174
c270a7d3889b36 Danielle Ratson 2024-06-17 175 err_msg_len = strlen(err_msg);
c270a7d3889b36 Danielle Ratson 2024-06-17 176 total_len = err_msg_len + 2; /* For period and NUL. */
c270a7d3889b36 Danielle Ratson 2024-06-17 177
c270a7d3889b36 Danielle Ratson 2024-06-17 178 if (sub_err_msg) {
c270a7d3889b36 Danielle Ratson 2024-06-17 179 sub_err_msg_len = strlen(sub_err_msg);
c270a7d3889b36 Danielle Ratson 2024-06-17 180 total_len += sub_err_msg_len + 2; /* For ", ". */
c270a7d3889b36 Danielle Ratson 2024-06-17 181 }
c270a7d3889b36 Danielle Ratson 2024-06-17 182
c270a7d3889b36 Danielle Ratson 2024-06-17 183 attr = nla_reserve(skb, ETHTOOL_A_MODULE_FW_FLASH_STATUS_MSG,
c270a7d3889b36 Danielle Ratson 2024-06-17 184 total_len);
c270a7d3889b36 Danielle Ratson 2024-06-17 185 if (!attr)c270a7d3889b36 Danielle Ratson 2024-06-17 @186 return PTR_ERR(attr);
This returns success. It should be return -ENOMEM;
c270a7d3889b36 Danielle Ratson 2024-06-17 187 c270a7d3889b36 Danielle Ratson 2024-06-17 188 if (sub_err_msg) c270a7d3889b36 Danielle Ratson 2024-06-17 189 sprintf(nla_data(attr), "%s, %s.", err_msg, sub_err_msg); c270a7d3889b36 Danielle Ratson 2024-06-17 190 else c270a7d3889b36 Danielle Ratson 2024-06-17 191 sprintf(nla_data(attr), "%s.", err_msg); c270a7d3889b36 Danielle Ratson 2024-06-17 192 c270a7d3889b36 Danielle Ratson 2024-06-17 193 return 0; c270a7d3889b36 Danielle Ratson 2024-06-17 194 }
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki