From patchwork Fri Jul 5 08:13:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 168508 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3249616ilk; Fri, 5 Jul 2019 01:13:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/ph3F5b6JnjBzeGlF7ColNfdN3HDCXS0dCcEYLLGaAgdzZWEmYYcymjg0ET88ZeZyd/Ht X-Received: by 2002:a17:902:4501:: with SMTP id m1mr3667591pld.111.1562314391534; Fri, 05 Jul 2019 01:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562314391; cv=none; d=google.com; s=arc-20160816; b=GyONmCrnuc2b5VcfVAL+X3EHopRwBrHkGd2n0cuFnHF3f2+I5gtI1rU6NszvOfPPAl S6XnYNZKZ+nYLSdXgHNweFAUT6ky1GKeFp9WqS674zD3fOzdlyLkWa/nZpHaQwV/wNyV ITRuarYvBg/HjPrVLiHlz6lRvyDQ2oyHrR1nl+ASrR3oa0mtiy9Y4+1J8lRCQ+Lbdbhy xYLV8dkWP/lhC9FeEN3eMZrMpAMBjClW3PUhfkAh/D9yO/v7pgaE0aAYvQBetggyjqxk nnRLydN9ZY2VV5BL+GXIYIs2OYTChIejLR/2CZyunQ9H0M6v0DVBVxSsQQM0XgnGfPxz G7og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=jjan+KgEz9G9OvUs3jK6RJyAXdEJ9Zg2rmXTwLxZscI=; b=jpuHUHwt7cFPrUSS9t/AErRS9yYTJfzmjQWhdIkTSakO5B09XsPV0ML34IArWA61Uw JefhhkQp2uaNxtw2in42ggDHWNF2pcRJPW8g2tiOyJ923vbVELcbPm4BqOrK7T2KYWeS hnWiTUpdKZdExv/oh2OhzNpjAj05dBhP+f/FU+MDgg5qGlR9oqQVrZE87axibzRg3VRn 6qHpAZMJTPBK6nlJMU5yc3rtHoZHApnkARBF9JJL/BgaYvkmqb7xGdCCJL8tT4R6Ax+j QEaA+tD1UqnGzP+sAvn3EwjOZ6DPkUSBWrmWOFCHbWbqZKnYhOSOH7GNIhTYWLxsV6cW vfHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LyTNlF16; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v8si3388539pgg.228.2019.07.05.01.13.11; Fri, 05 Jul 2019 01:13:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LyTNlF16; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727060AbfGEINJ (ORCPT + 30 others); Fri, 5 Jul 2019 04:13:09 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:54686 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726116AbfGEINJ (ORCPT ); Fri, 5 Jul 2019 04:13:09 -0400 Received: by mail-wm1-f66.google.com with SMTP id p74so4845131wme.4 for ; Fri, 05 Jul 2019 01:13:08 -0700 (PDT) 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=jjan+KgEz9G9OvUs3jK6RJyAXdEJ9Zg2rmXTwLxZscI=; b=LyTNlF16UwaW5NFWqEzepKuRWuQocXI0SgtwlvU3mh+zAL9Vq4QN4s1ygMPYtuJ0NH ZFwDzjtklZhj3sCVsDX9W10zt/IPpTTTsBReujQ6bSZPLZ9RGZwg3/D7+BABMF+imhOZ FVxhHehT/2pBDyv6H7jlry0KBNhplx5kSKZQfDm5fK/veT5FyPKbFC5MW1FmS+CIRaMz KqmF3mFIuZ8H57Z9L/TBfQrIFITk2pZZeesGZmbsTNO6c/VWdeJGWYwGvfhlb41esEyx tuCOxuUCJGNmnF/tarwzpscNxV3OdABQkA0Zo+ED3KF6p5+ptafQikyppiyz+FtuQ0Jr LTJQ== 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=jjan+KgEz9G9OvUs3jK6RJyAXdEJ9Zg2rmXTwLxZscI=; b=qLn8tyX6XIbIrhrqgUiP688DZVxw1LUGqleOp0n4fgqFXuzE2jAdDP3kz8UJMBHZFj iokwbzCzUTbfttseDMVJHxUOeLJJDLGmz4gb59BDe1OuDRUVLTEYr8JwpgoduWyICFci O9GcP+9P1YD2tCzg9qXivBh9dKwL0tW7EIWXm/Z7fRQnQVobMXsjU89lsK8J/dcqqQ4T XsTMsdlHATIgeHdrP3G731NIRUL/NSpOBG0HzQasl2qwq/j3rfagsURtfbCK/XSRISuh H8tg++Hio5w6BjrvUg8iSEjPOdNP+kgLnngsh69POTnzga0BT9rnpzUYtqal1VPuywlh nj1w== X-Gm-Message-State: APjAAAXdCDxNvSiDsfpvliWEIVDBQjh1VN0jWiLSoE0wXdxhAmtJRRxn LoumVjVSqNF/bbkvHckUvAUxFA== X-Received: by 2002:a1c:9e4d:: with SMTP id h74mr2295203wme.9.1562314387308; Fri, 05 Jul 2019 01:13:07 -0700 (PDT) Received: from localhost.localdomain (30.red-83-34-200.dynamicip.rima-tde.net. [83.34.200.30]) by smtp.gmail.com with ESMTPSA id 18sm7847141wmg.43.2019.07.05.01.13.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Jul 2019 01:13:06 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, arnd@arndb.de, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2] misc: fastrpc: fix memory leak Date: Fri, 5 Jul 2019 10:13:03 +0200 Message-Id: <20190705081303.14170-1-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Do the necessary house-keeping if the allocated memory wont be used Signed-off-by: Jorge Ramirez-Ortiz --- drivers/misc/fastrpc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.21.0 diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 98603e235cf0..c790585da14c 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -279,8 +279,11 @@ static int fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev, buf->virt = dma_alloc_coherent(dev, buf->size, (dma_addr_t *)&buf->phys, GFP_KERNEL); - if (!buf->virt) + if (!buf->virt) { + mutex_destroy(&buf->lock); + kfree(buf); return -ENOMEM; + } if (fl->sctx && fl->sctx->sid) buf->phys += ((u64)fl->sctx->sid << 32);