Skip to content

Commit 8a44189

Browse files
committed
Merge tag 'for-linus-fwctl' of git://git.kernel.org/pub/scm/linux/kernel/git/fwctl/fwctl
Pull fwctl updates from Jason Gunthorpe: - Fix mismatched kvalloc() kfree() on error paths - Remove NOP dev_err_probe(), shouldn't print on error paths anyhow - For mlx5 permit: MLX5_CMD_OP_MODIFY_CONG_STATUS MLX5_CMD_OP_QUERY_ADJACENT_FUNCTIONS_ID MLX5_CMD_OP_DELEGATE_VHCA_MANAGEMENT MLX5_CMD_OP_QUERY_DELEGATED_VHCA - Use memdup_user in pds * tag 'for-linus-fwctl' of git://git.kernel.org/pub/scm/linux/kernel/git/fwctl/fwctl: pds_fwctl: Replace kzalloc + copy_from_user with memdup_user in pdsfc_fw_rpc fwctl/mlx5: Add Adjacent function query commands and their scope fwctl/mlx5: Allow MODIFY_CONG_STATUS command pds_fwctl: Remove the use of dev_err_probe() fwctl/mlx5: Fix memory alloc/free in mlx5ctl_fw_rpc()
2 parents bed0653 + 479bec4 commit 8a44189

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

drivers/fwctl/mlx5/main.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ enum {
5858
MLX5_CMD_OP_QUERY_DC_CNAK_TRACE = 0x716,
5959
MLX5_CMD_OP_QUERY_NVMF_BACKEND_CONTROLLER = 0x722,
6060
MLX5_CMD_OP_QUERY_NVMF_NAMESPACE_CONTEXT = 0x728,
61+
MLX5_CMD_OP_QUERY_ADJACENT_FUNCTIONS_ID = 0x730,
62+
MLX5_CMD_OP_DELEGATE_VHCA_MANAGEMENT = 0x731,
63+
MLX5_CMD_OP_QUERY_DELEGATED_VHCA = 0x732,
6164
MLX5_CMD_OP_QUERY_BURST_SIZE = 0x813,
6265
MLX5_CMD_OP_QUERY_DIAGNOSTIC_PARAMS = 0x819,
6366
MLX5_CMD_OP_SET_DIAGNOSTIC_PARAMS = 0x820,
@@ -188,6 +191,7 @@ static bool mlx5ctl_validate_rpc(const void *in, enum fwctl_rpc_scope scope)
188191
* filter commands manually for now.
189192
*/
190193
switch (opcode) {
194+
case MLX5_CMD_OP_MODIFY_CONG_STATUS:
191195
case MLX5_CMD_OP_POSTPONE_CONNECTED_QP_TIMEOUT:
192196
case MLX5_CMD_OP_QUERY_ADAPTER:
193197
case MLX5_CMD_OP_QUERY_ESW_FUNCTIONS:
@@ -196,6 +200,7 @@ static bool mlx5ctl_validate_rpc(const void *in, enum fwctl_rpc_scope scope)
196200
case MLX5_CMD_OP_QUERY_OTHER_HCA_CAP:
197201
case MLX5_CMD_OP_QUERY_ROCE_ADDRESS:
198202
case MLX5_CMD_OPCODE_QUERY_VUID:
203+
case MLX5_CMD_OP_DELEGATE_VHCA_MANAGEMENT:
199204
/*
200205
* FW limits SET_HCA_CAP on the tools UID to only the other function
201206
* mode which is used for function pre-configuration
@@ -281,6 +286,8 @@ static bool mlx5ctl_validate_rpc(const void *in, enum fwctl_rpc_scope scope)
281286
case MLX5_CMD_OP_QUERY_XRQ:
282287
case MLX5_CMD_OP_USER_QUERY_XRQ_DC_PARAMS_ENTRY:
283288
case MLX5_CMD_OP_USER_QUERY_XRQ_ERROR_PARAMS:
289+
case MLX5_CMD_OP_QUERY_ADJACENT_FUNCTIONS_ID:
290+
case MLX5_CMD_OP_QUERY_DELEGATED_VHCA:
284291
return scope >= FWCTL_RPC_DEBUG_READ_ONLY;
285292

286293
case MLX5_CMD_OP_SET_DIAGNOSTIC_PARAMS:
@@ -345,7 +352,7 @@ static void *mlx5ctl_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
345352
*/
346353
if (ret && ret != -EREMOTEIO) {
347354
if (rpc_out != rpc_in)
348-
kfree(rpc_out);
355+
kvfree(rpc_out);
349356
return ERR_PTR(ret);
350357
}
351358
return rpc_out;

drivers/fwctl/pds/main.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/pci.h>
77
#include <linux/vmalloc.h>
88
#include <linux/bitfield.h>
9+
#include <linux/string.h>
910

1011
#include <uapi/fwctl/fwctl.h>
1112
#include <uapi/fwctl/pds.h>
@@ -366,18 +367,10 @@ static void *pdsfc_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
366367
return ERR_PTR(err);
367368

368369
if (rpc->in.len > 0) {
369-
in_payload = kzalloc(rpc->in.len, GFP_KERNEL);
370-
if (!in_payload) {
371-
dev_err(dev, "Failed to allocate in_payload\n");
372-
err = -ENOMEM;
373-
goto err_out;
374-
}
375-
376-
if (copy_from_user(in_payload, u64_to_user_ptr(rpc->in.payload),
377-
rpc->in.len)) {
370+
in_payload = memdup_user(u64_to_user_ptr(rpc->in.payload), rpc->in.len);
371+
if (IS_ERR(in_payload)) {
378372
dev_dbg(dev, "Failed to copy in_payload from user\n");
379-
err = -EFAULT;
380-
goto err_in_payload;
373+
return in_payload;
381374
}
382375

383376
in_payload_dma_addr = dma_map_single(dev->parent, in_payload,
@@ -453,7 +446,6 @@ static void *pdsfc_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
453446
rpc->in.len, DMA_TO_DEVICE);
454447
err_in_payload:
455448
kfree(in_payload);
456-
err_out:
457449
if (err)
458450
return ERR_PTR(err);
459451

@@ -481,7 +473,7 @@ static int pdsfc_probe(struct auxiliary_device *adev,
481473
pdsfc = fwctl_alloc_device(&padev->vf_pdev->dev, &pdsfc_ops,
482474
struct pdsfc_dev, fwctl);
483475
if (!pdsfc)
484-
return dev_err_probe(dev, -ENOMEM, "Failed to allocate fwctl device struct\n");
476+
return -ENOMEM;
485477
pdsfc->padev = padev;
486478

487479
err = pdsfc_identify(pdsfc);

0 commit comments

Comments
 (0)