Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rds: avoid calling sock_kfree_s() on allocation failure

It is okay to free a NULL pointer but not okay to mischarge the socket optmem
accounting. Compile test only.

Reported-by: rucsoftsec@gmail.com
Cc: Chien Yen <chien.yen@oracle.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Cong Wang <cwang@twopensource.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Cong Wang and committed by
David S. Miller
dee49f20 22c0b963

+4 -3
+4 -3
net/rds/rdma.c
··· 564 564 565 565 if (rs->rs_bound_addr == 0) { 566 566 ret = -ENOTCONN; /* XXX not a great errno */ 567 - goto out; 567 + goto out_ret; 568 568 } 569 569 570 570 if (args->nr_local > UIO_MAXIOV) { 571 571 ret = -EMSGSIZE; 572 - goto out; 572 + goto out_ret; 573 573 } 574 574 575 575 /* Check whether to allocate the iovec area */ ··· 578 578 iovs = sock_kmalloc(rds_rs_to_sk(rs), iov_size, GFP_KERNEL); 579 579 if (!iovs) { 580 580 ret = -ENOMEM; 581 - goto out; 581 + goto out_ret; 582 582 } 583 583 } 584 584 ··· 696 696 if (iovs != iovstack) 697 697 sock_kfree_s(rds_rs_to_sk(rs), iovs, iov_size); 698 698 kfree(pages); 699 + out_ret: 699 700 if (ret) 700 701 rds_rdma_free_op(op); 701 702 else