mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 01:53:29 +02:00
IB/rxe: avoid srq memory leak
In rxe_queue_init, q and q->buf are allocated. In do_mmap_info, q->ip is allocated. When error occurs, rxe_srq_from_init and the later error handler do not free these allocated memories. This will make memory leak. Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
parent
39f2495618
commit
aae0484e15
|
|
@ -31,6 +31,7 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <linux/vmalloc.h>
|
||||||
#include "rxe.h"
|
#include "rxe.h"
|
||||||
#include "rxe_loc.h"
|
#include "rxe_loc.h"
|
||||||
#include "rxe_queue.h"
|
#include "rxe_queue.h"
|
||||||
|
|
@ -129,13 +130,18 @@ int rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq,
|
||||||
|
|
||||||
err = do_mmap_info(rxe, uresp ? &uresp->mi : NULL, context, q->buf,
|
err = do_mmap_info(rxe, uresp ? &uresp->mi : NULL, context, q->buf,
|
||||||
q->buf_size, &q->ip);
|
q->buf_size, &q->ip);
|
||||||
if (err)
|
if (err) {
|
||||||
|
vfree(q->buf);
|
||||||
|
kfree(q);
|
||||||
return err;
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
if (uresp) {
|
if (uresp) {
|
||||||
if (copy_to_user(&uresp->srq_num, &srq->srq_num,
|
if (copy_to_user(&uresp->srq_num, &srq->srq_num,
|
||||||
sizeof(uresp->srq_num)))
|
sizeof(uresp->srq_num))) {
|
||||||
|
rxe_queue_cleanup(q);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user