From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Julia Lawall <julia.lawall@inria.fr>
Subject: [djiang:cxl/fwctl 8/26] drivers/fwctl/mlx5/main.c:277:16-17: WARNING kvmalloc is used to allocate this memory at line 256
Date: Sat, 8 Feb 2025 14:23:59 +0800 [thread overview]
Message-ID: <202502081426.rdLK0kD9-lkp@intel.com> (raw)
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: Saeed Mahameed <saeedm@nvidia.com>
CC: Dave Jiang <dave.jiang@intel.com>
CC: Jonathan Cameron <Jonathan.Cameron@huawei.com>
CC: Jason Gunthorpe <jgg@nvidia.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/djiang/linux.git cxl/fwctl
head: 2ad713178275250c08fd3df6682dff12d01ff33c
commit: 57f4835341028d751c1e25fef0d8978cc19bb1d9 [8/26] fwctl/mlx5: Support for communicating with mlx5 fw
:::::: branch date: 7 hours ago
:::::: commit date: 15 hours ago
config: s390-randconfig-r064-20250208 (https://download.01.org/0day-ci/archive/20250208/202502081426.rdLK0kD9-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
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 <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202502081426.rdLK0kD9-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> drivers/fwctl/mlx5/main.c:277:16-17: WARNING kvmalloc is used to allocate this memory at line 256
vim +277 drivers/fwctl/mlx5/main.c
57f4835341028d Saeed Mahameed 2025-02-06 227
57f4835341028d Saeed Mahameed 2025-02-06 228 static void *mlx5ctl_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
57f4835341028d Saeed Mahameed 2025-02-06 229 void *rpc_in, size_t in_len, size_t *out_len)
57f4835341028d Saeed Mahameed 2025-02-06 230 {
57f4835341028d Saeed Mahameed 2025-02-06 231 struct mlx5ctl_dev *mcdev =
57f4835341028d Saeed Mahameed 2025-02-06 232 container_of(uctx->fwctl, struct mlx5ctl_dev, fwctl);
57f4835341028d Saeed Mahameed 2025-02-06 233 struct mlx5ctl_uctx *mfd =
57f4835341028d Saeed Mahameed 2025-02-06 234 container_of(uctx, struct mlx5ctl_uctx, uctx);
57f4835341028d Saeed Mahameed 2025-02-06 235 void *rpc_out;
57f4835341028d Saeed Mahameed 2025-02-06 236 int ret;
57f4835341028d Saeed Mahameed 2025-02-06 237
57f4835341028d Saeed Mahameed 2025-02-06 238 if (in_len < MLX5_ST_SZ_BYTES(mbox_in_hdr) ||
57f4835341028d Saeed Mahameed 2025-02-06 239 *out_len < MLX5_ST_SZ_BYTES(mbox_out_hdr))
57f4835341028d Saeed Mahameed 2025-02-06 240 return ERR_PTR(-EMSGSIZE);
57f4835341028d Saeed Mahameed 2025-02-06 241
57f4835341028d Saeed Mahameed 2025-02-06 242 mlx5ctl_dbg(mcdev, "[UID %d] cmdif: opcode 0x%x inlen %zu outlen %zu\n",
57f4835341028d Saeed Mahameed 2025-02-06 243 mfd->uctx_uid, MLX5_GET(mbox_in_hdr, rpc_in, opcode),
57f4835341028d Saeed Mahameed 2025-02-06 244 in_len, *out_len);
57f4835341028d Saeed Mahameed 2025-02-06 245
57f4835341028d Saeed Mahameed 2025-02-06 246 if (!mlx5ctl_validate_rpc(rpc_in, scope))
57f4835341028d Saeed Mahameed 2025-02-06 247 return ERR_PTR(-EBADMSG);
57f4835341028d Saeed Mahameed 2025-02-06 248
57f4835341028d Saeed Mahameed 2025-02-06 249 /*
57f4835341028d Saeed Mahameed 2025-02-06 250 * mlx5_cmd_do() copies the input message to its own buffer before
57f4835341028d Saeed Mahameed 2025-02-06 251 * executing it, so we can reuse the allocation for the output.
57f4835341028d Saeed Mahameed 2025-02-06 252 */
57f4835341028d Saeed Mahameed 2025-02-06 253 if (*out_len <= in_len) {
57f4835341028d Saeed Mahameed 2025-02-06 254 rpc_out = rpc_in;
57f4835341028d Saeed Mahameed 2025-02-06 255 } else {
57f4835341028d Saeed Mahameed 2025-02-06 @256 rpc_out = kvzalloc(*out_len, GFP_KERNEL);
57f4835341028d Saeed Mahameed 2025-02-06 257 if (!rpc_out)
57f4835341028d Saeed Mahameed 2025-02-06 258 return ERR_PTR(-ENOMEM);
57f4835341028d Saeed Mahameed 2025-02-06 259 }
57f4835341028d Saeed Mahameed 2025-02-06 260
57f4835341028d Saeed Mahameed 2025-02-06 261 /* Enforce the user context for the command */
57f4835341028d Saeed Mahameed 2025-02-06 262 MLX5_SET(mbox_in_hdr, rpc_in, uid, mfd->uctx_uid);
57f4835341028d Saeed Mahameed 2025-02-06 263 ret = mlx5_cmd_do(mcdev->mdev, rpc_in, in_len, rpc_out, *out_len);
57f4835341028d Saeed Mahameed 2025-02-06 264
57f4835341028d Saeed Mahameed 2025-02-06 265 mlx5ctl_dbg(mcdev,
57f4835341028d Saeed Mahameed 2025-02-06 266 "[UID %d] cmdif: opcode 0x%x status 0x%x retval %pe\n",
57f4835341028d Saeed Mahameed 2025-02-06 267 mfd->uctx_uid, MLX5_GET(mbox_in_hdr, rpc_in, opcode),
57f4835341028d Saeed Mahameed 2025-02-06 268 MLX5_GET(mbox_out_hdr, rpc_out, status), ERR_PTR(ret));
57f4835341028d Saeed Mahameed 2025-02-06 269
57f4835341028d Saeed Mahameed 2025-02-06 270 /*
57f4835341028d Saeed Mahameed 2025-02-06 271 * -EREMOTEIO means execution succeeded and the out is valid,
57f4835341028d Saeed Mahameed 2025-02-06 272 * but an error code was returned inside out. Everything else
57f4835341028d Saeed Mahameed 2025-02-06 273 * means the RPC did not make it to the device.
57f4835341028d Saeed Mahameed 2025-02-06 274 */
57f4835341028d Saeed Mahameed 2025-02-06 275 if (ret && ret != -EREMOTEIO) {
57f4835341028d Saeed Mahameed 2025-02-06 276 if (rpc_out != rpc_in)
57f4835341028d Saeed Mahameed 2025-02-06 @277 kfree(rpc_out);
57f4835341028d Saeed Mahameed 2025-02-06 278 return ERR_PTR(ret);
57f4835341028d Saeed Mahameed 2025-02-06 279 }
57f4835341028d Saeed Mahameed 2025-02-06 280 return rpc_out;
57f4835341028d Saeed Mahameed 2025-02-06 281 }
57f4835341028d Saeed Mahameed 2025-02-06 282
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2025-02-08 6:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202502081426.rdLK0kD9-lkp@intel.com \
--to=lkp@intel.com \
--cc=julia.lawall@inria.fr \
--cc=oe-kbuild@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.