Skip to content

Commit

Permalink
mlx4_core: Don't leak mailbox for SET_PORT on Ethernet ports
Browse files Browse the repository at this point in the history
Commit 793730b ("mlx4_core: Don't perform SET_PORT command for
Ethernet ports") introduced a leak of mailbox buffers when SET_PORT
was called for Ethernet ports, since it added a return after the
mailbox was allocated.  Fix this by checking the port type and
returning *before* allocating the mailbox.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
  • Loading branch information
Roland Dreier committed Mar 31, 2009
1 parent e1d60ec commit 352b09e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/net/mlx4/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,14 @@ int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port)
struct mlx4_cmd_mailbox *mailbox;
int err;

if (dev->caps.port_type[port] == MLX4_PORT_TYPE_ETH)
return 0;

mailbox = mlx4_alloc_cmd_mailbox(dev);
if (IS_ERR(mailbox))
return PTR_ERR(mailbox);

memset(mailbox->buf, 0, 256);
if (dev->caps.port_type[port] == MLX4_PORT_TYPE_ETH)
return 0;

((__be32 *) mailbox->buf)[1] = dev->caps.ib_port_def_cap[port];
err = mlx4_cmd(dev, mailbox->dma, port, 0, MLX4_CMD_SET_PORT,
Expand Down

0 comments on commit 352b09e

Please sign in to comment.