From patchwork Thu Jan 7 20:26:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 358260 Delivered-To: patches@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp783483jai; Thu, 7 Jan 2021 12:26:20 -0800 (PST) X-Received: by 2002:a63:e246:: with SMTP id y6mr3522532pgj.412.1610051180356; Thu, 07 Jan 2021 12:26:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610051180; cv=none; d=google.com; s=arc-20160816; b=O+cQq3V4XjDa3IsibczXGN749qIyiWZSpU+N6Tjh4fF3nrlXZ96n7BWrJt5tBS+Pl2 EptemiJWgrLw+L9ZSQIplQuA1XjIpekE5Hj6O7cbsFk6JAHSCgHWt+C46v8xJVx/clTJ uWFnhjo4FvnybmXz3k5hVyn6fX+XEJiZLdFyAoxTXs5ooyFTyPXHwd5kM3BPmh4QE7J5 Jw9Y3d0v+bFTD0a44Ajxzu2NiSCTUx8m92OPY8rqECqw0PdlJRR8nXshT8+JYA3msgFJ GbuoA9+F7GcI8mIzUCTVyCrIc3fownXkNEhHVUnlAKHtGpEbphSI8yTMFRkcw+nt1J7b dmPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=U9M2e+GyD9N3kdkTu1dWZpMp+TAsO6qz5jF42PL+fHo=; b=lj6x4eoFGsQDBuVMVvl80jIiy2ilFQ0Dl8LGbdMmQGj/pCY8Ic3+Y6JpAMsYBEMFKz IlPD//fWxWTdvszWCJfA9aOV6PTTQhkBa+xTY2hI8fyYLfVPtw17d832bYi/eLsGOF1o 34ydzaUG7ttGWK4NXXcpyhdAjTcEvJjgGNKGbBuiNXaTBpiThDo5CRHTRPO6gb31ll4c 1TJoxkfH4w8kUhZagJIiIszyuCn1UPdaSe6cjAEL1i/j48sYa6GcgtWJKq3UHmDlOXXf Mxu8hrGUzlZhIhN3lJ3z3PTH+s8Iyqbz4reL8/MoishaRV2QkuyXXcM9fwQauxtxt9AL bwjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PdcvmPrs; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 18sor3483447pjk.42.2021.01.07.12.26.20 for (Google Transport Security); Thu, 07 Jan 2021 12:26:20 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PdcvmPrs; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=U9M2e+GyD9N3kdkTu1dWZpMp+TAsO6qz5jF42PL+fHo=; b=PdcvmPrsZTt84GZCS+kSt2fsYPUuWBnUZ6TgSGrzQm7LMI06dViN+9q1BlvX3wKwvy 1wk7rj1JVz438UvHsZkQev7kMal1vDAykDsfxC7na5m4/YFebvq9SSUKtS9Y0YF4N/OF whDN3W5ZGFo6U3kffrK2ffFmsDsrro0IYJE2cc7EPQDaGOrY7OAee/+wtZPbpDlgGgAL r8gQLptYjvGMrb7QH8D/qwA29QjZF6SuWybgWBfUtX3P53vcbGm0db0nba5hWgQ888ZK n+32dBm5G6GBN1TV8lD0c2epBxo233wXHEb1OEUoqkyDzv+UgJ+vMhEXBEPVTXNetmQA x0SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=U9M2e+GyD9N3kdkTu1dWZpMp+TAsO6qz5jF42PL+fHo=; b=C0bBAtxPAUDg9tBGVuFJB4lfCB7oPy+FsGeo+AwNm+s6GCFi6blnBqiURktY1Jeffv cJecAq8dnTm7EcRYZxuuroAboDFjQTO773f/h5OfABwr0DttK+/5YqeGdXIfoV+c4/xG sf3Lg1OXCA7CJf6xQePXRpsTTCRhXMDqc/09T4IFtg1cNCw/MI7B3co84E8pmnjCQWJr avwN8uFy1gXigg5lvKwLSOCbwcbxs3lqqpJzyPS7Vciz6FrjbMH9PLkiLqoygvwcgD5l OB7RinRUfOzI3xGlNcX/NXufpHD+2GZ0OcFzcTdfai4SfZ27By2PgygdOM7VJFdW5Bzq bqDw== X-Gm-Message-State: AOAM5304rTsaOzxqM6au12s3RUgfBn5WzFALOtvO4uGY+ucZbaphVCnt W3yRzH/OCfIg7NDBmBleQQ+SQbyP X-Google-Smtp-Source: ABdhPJzFeKvAsLz8R7Rwlkdtsye3bkYdvaN9gR1Ris0ONyaGl04w2s13SWnH/vv8k+BsZYzGRRZY/w== X-Received: by 2002:a17:90a:3948:: with SMTP id n8mr216103pjf.206.1610051180075; Thu, 07 Jan 2021 12:26:20 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q9sm7042112pgb.82.2021.01.07.12.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:26:19 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Bing Song , Sumit Semwal , Liam Mark , Laura Abbott , Brian Starkey , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , Daniel Mentz , Chris Goldsworthy , =?utf-8?q?=C3=98rjan_Eide?= , Robin Murphy , Ezequiel Garcia , Simon Ser , James Jones , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH] dma-buf: cma_heap: Fix memory leak in CMA heap Date: Thu, 7 Jan 2021 20:26:16 +0000 Message-Id: <20210107202616.75170-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Bing Song noticed the CMA heap was leaking memory due to a flub I made in commit a5d2d29e24be ("dma-buf: heaps: Move heap-helper logic into the cma_heap implementation"), and provided this fix which ensures the pagelist is also freed on release. Cc: Bing Song Cc: Sumit Semwal Cc: Liam Mark Cc: Laura Abbott Cc: Brian Starkey Cc: Hridya Valsaraju Cc: Suren Baghdasaryan Cc: Sandeep Patil Cc: Daniel Mentz Cc: Chris Goldsworthy Cc: Ørjan Eide Cc: Robin Murphy Cc: Ezequiel Garcia Cc: Simon Ser Cc: James Jones Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Reported-by: Bing Song Fixes: a5d2d29e24be ("dma-buf: heaps: Move heap-helper logic into the cma_heap implementation") Signed-off-by: John Stultz --- drivers/dma-buf/heaps/cma_heap.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.17.1 diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c index 3c4e34301172..364fc2f3e499 100644 --- a/drivers/dma-buf/heaps/cma_heap.c +++ b/drivers/dma-buf/heaps/cma_heap.c @@ -251,6 +251,9 @@ static void cma_heap_dma_buf_release(struct dma_buf *dmabuf) buffer->vaddr = NULL; } + /* free page list */ + kfree(buffer->pages); + /* release memory */ cma_release(cma_heap->cma, buffer->cma_pages, buffer->pagecount); kfree(buffer); }