Commit 8a44189f authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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()
parents bed0653f 479bec4c
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -58,6 +58,9 @@ enum {
	MLX5_CMD_OP_QUERY_DC_CNAK_TRACE = 0x716,
	MLX5_CMD_OP_QUERY_NVMF_BACKEND_CONTROLLER = 0x722,
	MLX5_CMD_OP_QUERY_NVMF_NAMESPACE_CONTEXT = 0x728,
	MLX5_CMD_OP_QUERY_ADJACENT_FUNCTIONS_ID = 0x730,
	MLX5_CMD_OP_DELEGATE_VHCA_MANAGEMENT = 0x731,
	MLX5_CMD_OP_QUERY_DELEGATED_VHCA = 0x732,
	MLX5_CMD_OP_QUERY_BURST_SIZE = 0x813,
	MLX5_CMD_OP_QUERY_DIAGNOSTIC_PARAMS = 0x819,
	MLX5_CMD_OP_SET_DIAGNOSTIC_PARAMS = 0x820,
@@ -188,6 +191,7 @@ static bool mlx5ctl_validate_rpc(const void *in, enum fwctl_rpc_scope scope)
	 * filter commands manually for now.
	 */
	switch (opcode) {
	case MLX5_CMD_OP_MODIFY_CONG_STATUS:
	case MLX5_CMD_OP_POSTPONE_CONNECTED_QP_TIMEOUT:
	case MLX5_CMD_OP_QUERY_ADAPTER:
	case MLX5_CMD_OP_QUERY_ESW_FUNCTIONS:
@@ -196,6 +200,7 @@ static bool mlx5ctl_validate_rpc(const void *in, enum fwctl_rpc_scope scope)
	case MLX5_CMD_OP_QUERY_OTHER_HCA_CAP:
	case MLX5_CMD_OP_QUERY_ROCE_ADDRESS:
	case MLX5_CMD_OPCODE_QUERY_VUID:
	case MLX5_CMD_OP_DELEGATE_VHCA_MANAGEMENT:
	/*
	 * FW limits SET_HCA_CAP on the tools UID to only the other function
	 * 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)
	case MLX5_CMD_OP_QUERY_XRQ:
	case MLX5_CMD_OP_USER_QUERY_XRQ_DC_PARAMS_ENTRY:
	case MLX5_CMD_OP_USER_QUERY_XRQ_ERROR_PARAMS:
	case MLX5_CMD_OP_QUERY_ADJACENT_FUNCTIONS_ID:
	case MLX5_CMD_OP_QUERY_DELEGATED_VHCA:
		return scope >= FWCTL_RPC_DEBUG_READ_ONLY;

	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,
	 */
	if (ret && ret != -EREMOTEIO) {
		if (rpc_out != rpc_in)
			kfree(rpc_out);
			kvfree(rpc_out);
		return ERR_PTR(ret);
	}
	return rpc_out;
+5 −13
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
#include <linux/pci.h>
#include <linux/vmalloc.h>
#include <linux/bitfield.h>
#include <linux/string.h>

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

	if (rpc->in.len > 0) {
		in_payload = kzalloc(rpc->in.len, GFP_KERNEL);
		if (!in_payload) {
			dev_err(dev, "Failed to allocate in_payload\n");
			err = -ENOMEM;
			goto err_out;
		}

		if (copy_from_user(in_payload, u64_to_user_ptr(rpc->in.payload),
				   rpc->in.len)) {
		in_payload = memdup_user(u64_to_user_ptr(rpc->in.payload), rpc->in.len);
		if (IS_ERR(in_payload)) {
			dev_dbg(dev, "Failed to copy in_payload from user\n");
			err = -EFAULT;
			goto err_in_payload;
			return in_payload;
		}

		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,
				 rpc->in.len, DMA_TO_DEVICE);
err_in_payload:
	kfree(in_payload);
err_out:
	if (err)
		return ERR_PTR(err);

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

	err = pdsfc_identify(pdsfc);