From patchwork Wed Sep 30 12:36:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 54325 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id 4F26B22E23 for ; Wed, 30 Sep 2015 12:36:30 +0000 (UTC) Received: by labjc2 with SMTP id jc2sf12409802lab.1 for ; Wed, 30 Sep 2015 05:36:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=218di/mT7h0UzuJTVZPChNtnMk/nTVUZAk4nPlujjgI=; b=OdfxWhC1nadUoMjL6de7AwB052XErlzIpjYOH+VVV0GduYoc33+z2Hp3TFbzqgphZ3 Le7h8Ch0oY+E4F9ZPoa09tVZG0y/AvzQ7k6wIUJx+IO37Mqbw/pa8UGWZAXpfL0aiFBu 7E5Qyb8A/IwO7hpwDfMl7AiFTsIIqTOiOD2+mSbcRGSNrbdUihMOsMfsxX1Pkfw1SS3P vtYjb0JB8s18oIcIl04Z9oOmP0iHv4hzMXSQUzKezoEGNH5iE/8bR/058WYV1TwhYW1G P5QBIV+9wmGYtXl3pjW0Uj6cn71Z+I07oflOwRAjRG2QgH2g3kjv0B+nGiXj9f0GO8il 7F2g== X-Gm-Message-State: ALoCoQk7UjNEKnX3lZGEkTvHG2gfR+B6QMC3H4dZx83TRyeIeRmkjwsuRn2i1NNf++IbyHcXwcsx X-Received: by 10.152.120.232 with SMTP id lf8mr508237lab.1.1443616588835; Wed, 30 Sep 2015 05:36:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.25.67 with SMTP id 64ls38692lfz.41.gmail; Wed, 30 Sep 2015 05:36:28 -0700 (PDT) X-Received: by 10.25.38.9 with SMTP id m9mr658259lfm.112.1443616588667; Wed, 30 Sep 2015 05:36:28 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id a135si178367lfe.135.2015.09.30.05.36.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Sep 2015 05:36:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by lahh2 with SMTP id h2so44213608lah.0 for ; Wed, 30 Sep 2015 05:36:28 -0700 (PDT) X-Received: by 10.112.156.167 with SMTP id wf7mr1032807lbb.88.1443616588363; Wed, 30 Sep 2015 05:36:28 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp2729312lbq; Wed, 30 Sep 2015 05:36:27 -0700 (PDT) X-Received: by 10.107.152.134 with SMTP id a128mr4026433ioe.164.1443616587232; Wed, 30 Sep 2015 05:36:27 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id kt2si394973igb.45.2015.09.30.05.36.24; Wed, 30 Sep 2015 05:36:27 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755467AbbI3MgW (ORCPT + 30 others); Wed, 30 Sep 2015 08:36:22 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:33053 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754899AbbI3MgU (ORCPT ); Wed, 30 Sep 2015 08:36:20 -0400 Received: by wiclk2 with SMTP id lk2so195940712wic.0 for ; Wed, 30 Sep 2015 05:36:19 -0700 (PDT) X-Received: by 10.180.9.112 with SMTP id y16mr32997881wia.28.1443616579225; Wed, 30 Sep 2015 05:36:19 -0700 (PDT) Received: from localhost.localdomain (host-92-13-246-184.as43234.net. [92.13.246.184]) by smtp.gmail.com with ESMTPSA id mc20sm524574wic.16.2015.09.30.05.36.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Sep 2015 05:36:18 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: maxime.ripard@free-electrons.com, linux-kernel@vger.kernel.org, srinivas.kandagatla@linaro.org, linux-arm-kernel@lists.infradead.org, Axel Lin Subject: [PATCH 3/4] nvmem: core: Fix memory leak in nvmem_cell_write Date: Wed, 30 Sep 2015 13:36:10 +0100 Message-Id: <1443616570-17825-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1443616298-17389-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1443616298-17389-1-git-send-email-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: srinivas.kandagatla@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Axel Lin A tmp buffer is allocated if cell->bit_offset || cell->nbits. So the tmp buffer needs to be freed at the same condition to avoid leak. Signed-off-by: Axel Lin Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 676607c..6fd4e5a 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -938,7 +938,7 @@ int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len) rc = regmap_raw_write(nvmem->regmap, cell->offset, buf, cell->bytes); /* free the tmp buffer */ - if (cell->bit_offset) + if (cell->bit_offset || cell->nbits) kfree(buf); if (IS_ERR_VALUE(rc))