Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3223540ybg; Mon, 28 Oct 2019 09:21:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJ1CzXS4DdJnDjHSfkNH9l7tlS7bA+ch4l2nbCs9bBt8uxZ4jVWBKvAlJsHGNfvBBlSZqp X-Received: by 2002:a17:906:cc9a:: with SMTP id oq26mr16816394ejb.292.1572279661187; Mon, 28 Oct 2019 09:21:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572279661; cv=none; d=google.com; s=arc-20160816; b=CNG2pBvczkWoLcJVtdIgYegfuqV2HpsSJsZdavNb1MychB/JPZlbeZaYss0YmJ9FAW cG/Vpf7pL+IxtLVIi7m49gC4yIMMUg5a5d+QSAxUiwK8Kx5eBTspvHdexXgMHGmbaAjP ObrvkfBvMwgjynTtHb/wTlslfBiM5OJotEAJL+XsJqq5u17/6gXIutTLfA51s9ZynpHM 0kvtdO0RVxBkBH6b+0caYTvJPj+SfXJspI6SDWN+dilwXTGbM4qe4F0toYYvhLgtu36R zsR1XbQONgd8x9163ThbCMkDqZLd33VHVFOOsNxigl5I4cdPkpKeolyVplNFebsZ3rlJ iFYA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=BHw7OWoQQRD9TLD3r6XHFm46yNvBtUwfaJ3ESCbgi1A=; b=oHMs4yrZc7s+teQxo23u17uI6YbRIcCyKJFN5MMroi5hE5sbfS85wToGBhZs9VZu6C 2aL4A5eELXTstgWqO2p2sgwL5meZZyKlJcbogf3PbEyPaaTZ7+q1dUyE+7xrcJjZEwUX 9v9qjxLS0YFTG/qxLC68M7mcRjfVWN3GXlvdjCunhibKiH2O5ZtqOUVLaDNrTNyxLK7k VgfX0zY36aGCzUh/iQdZmGiXLk6X/5lzxYCrDKsIdYnhtE5X2mL8gNm9+6hUUOMbnyK7 eAhvRcVpJp/x0PetUuUjYLnq8F+9BMvqUWKH/H/+aiTI0+jw/qdX1LimVp14R1uFPc9N R0VA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d15si7234832edn.49.2019.10.28.09.20.36; Mon, 28 Oct 2019 09:21:01 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732405AbfJ1HHj (ORCPT + 99 others); Mon, 28 Oct 2019 03:07:39 -0400 Received: from mga18.intel.com ([134.134.136.126]:19783 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732280AbfJ1HHY (ORCPT ); Mon, 28 Oct 2019 03:07:24 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Oct 2019 00:07:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,239,1569308400"; d="scan'208";a="205111248" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 28 Oct 2019 00:07:22 -0700 From: Alexander Shishkin To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Wei Yongjun , Alexander Shishkin , Andy Shevchenko Subject: [GIT PULL 5/7] intel_th: msu: Fix possible memory leak in mode_store() Date: Mon, 28 Oct 2019 09:06:49 +0200 Message-Id: <20191028070651.9770-6-alexander.shishkin@linux.intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191028070651.9770-1-alexander.shishkin@linux.intel.com> References: <20191028070651.9770-1-alexander.shishkin@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wei Yongjun 'mode' is malloced in mode_store() and should be freed before leaving from the error handling cases, otherwise it will cause memory leak. Fixes: 615c164da0eb ("intel_th: msu: Introduce buffer interface") Signed-off-by: Wei Yongjun Signed-off-by: Alexander Shishkin Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/lkml/20190801013825.182543-1-weiyongjun1@huawei.com/ --- drivers/hwtracing/intel_th/msu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c index 9dc9ae87b5e5..6d240dfae9d9 100644 --- a/drivers/hwtracing/intel_th/msu.c +++ b/drivers/hwtracing/intel_th/msu.c @@ -1852,8 +1852,10 @@ mode_store(struct device *dev, struct device_attribute *attr, const char *buf, return -ENOMEM; i = match_string(msc_mode, ARRAY_SIZE(msc_mode), mode); - if (i >= 0) + if (i >= 0) { + kfree(mode); goto found; + } /* Buffer sinks only work with a usable IRQ */ if (!msc->do_irq) { -- 2.23.0