Skip to content

Commit

Permalink
rds: avoid calling sock_kfree_s() on allocation failure
Browse files Browse the repository at this point in the history
It is okay to free a NULL pointer but not okay to mischarge the socket optmem
accounting. Compile test only.

Reported-by: [email protected]
Cc: Chien Yen <[email protected]>
Cc: Stephen Hemminger <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
congwang1986 authored and davem330 committed Oct 14, 2014
1 parent 22c0b96 commit dee49f2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions net/rds/rdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,12 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm,

if (rs->rs_bound_addr == 0) {
ret = -ENOTCONN; /* XXX not a great errno */
goto out;
goto out_ret;
}

if (args->nr_local > UIO_MAXIOV) {
ret = -EMSGSIZE;
goto out;
goto out_ret;
}

/* Check whether to allocate the iovec area */
Expand All @@ -578,7 +578,7 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm,
iovs = sock_kmalloc(rds_rs_to_sk(rs), iov_size, GFP_KERNEL);
if (!iovs) {
ret = -ENOMEM;
goto out;
goto out_ret;
}
}

Expand Down Expand Up @@ -696,6 +696,7 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm,
if (iovs != iovstack)
sock_kfree_s(rds_rs_to_sk(rs), iovs, iov_size);
kfree(pages);
out_ret:
if (ret)
rds_rdma_free_op(op);
else
Expand Down

0 comments on commit dee49f2

Please sign in to comment.