Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3851027ybi; Mon, 27 May 2019 07:07:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqcaGwEXLYST6g7gQGndVJqwPtI3LVdtIV7iR1nu4qRZ9cWDzARZxBtNvrLErWXDo9g742 X-Received: by 2002:a17:902:204:: with SMTP id 4mr75514236plc.21.1558966021348; Mon, 27 May 2019 07:07:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558966021; cv=none; d=google.com; s=arc-20160816; b=bHw36xDSWak9SIO/KU69omOMF50cFmvpNwWlL7wv9tFLBLyPJvzorsO5hvO6nOuP5H JZt8SkS1MyWg6hIqzFdWB8gRvNHPVX6G0vvAH1TbD7odaUHKl5PYR1t7TFMsARZ0fG+4 pQxqv1J1yujUdS8EnQxdyV7XawhpYPSrKBWHwrFOW44nDYNVfz8f1pNMTJ+j0vL888nD lPRmHPlgKfNWUNGqZs6BILonyziS/6DwLLPbhCrrzhpVfZUrwvkoMOznI4pdoFgwUNgu tCDxpwXUfj/GNmwHFMaaP0KHpTG99IdiJeuE14R6HIxUG29x0Fw2JrXziJ/lop/Ilve8 bn7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=yp6vwmQ3UFg1RpTqex0tXos3VmAEaOYrUMRIMtSICN0=; b=nTcTDE4Laa/IwZ0N2/7QckJ91vxQb66IJBswEJI+GSFAWlPLZBC+IXtDFcKlewxMit cZxoHnUqerKo++tRiYu7J9XeONJZQo86JihZPID1ZmskBGxa4GPYpqElG357UmIa1urh iXnLt93SP2lD04JMsAqSdQfWqVSNLOWbmwv5ZmalhwZpm0Xg2YWyHnvSxGjrnzr9ub8D i5RH27qHWKI5+4tcMqSkGaFVtdEF3OJ8ZSLcoEDBlnV7MXoRU+nrEyVgSRZx74war8Z0 2iGyceckPlcipgLRCTIi5lWJPLVDh0WsMBNbYOQzFowYjgu4pR/onI5gIkq1zArUIDa2 JsHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=juJeAFhe; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 65si17934021plb.39.2019.05.27.07.06.45; Mon, 27 May 2019 07:07: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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=juJeAFhe; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbfE0OEp (ORCPT + 99 others); Mon, 27 May 2019 10:04:45 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:32824 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726184AbfE0OEo (ORCPT ); Mon, 27 May 2019 10:04:44 -0400 Received: by mail-pg1-f194.google.com with SMTP id h17so9194977pgv.0; Mon, 27 May 2019 07:04:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=yp6vwmQ3UFg1RpTqex0tXos3VmAEaOYrUMRIMtSICN0=; b=juJeAFheYBekNJQSoLUu8sN+VcoG8lAExtn/Q2xLayDMWJ+rVcSx3A5dew4RTixMRj 3qh6nUbfTgGBLg5BZfcOuKzBjLmzObH911VnvKzeF7GZN/QjZ4i8sivx8htfkHnk9AL1 GBP3RqKQ2Q63Vj8j+OpR1cY3C1XHdFBRD8EAF+1xAzUvAlVTpsLHjoIQP33L4h6RVRA5 lmGhtSuT7hPuNZZUHpEW9qVdURrIY8fxTcCDMEaI81TEn1/PBlUNqhupoOgzgx9Oac6L O1JVD9mdmfHx+9Aji6dPIRdU/bggPeD5quZ8hmUvrqvH47mdFk36XiZ/GVaYVqEyS6pZ P/6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=yp6vwmQ3UFg1RpTqex0tXos3VmAEaOYrUMRIMtSICN0=; b=Dhy9YHUEKM7HkjKznREQ2HhWpXjPp5sq8/P4IneW7IfxGS8pjyxZEcuXnmZLMGkLSJ Jgmesrpx6YGtfxiIX7OFtwhWhUNBhJ+ynoKKTNBLScf15XGgROOL/vP5biymQs8mVxMz PcFQPft+zimfqvX+gpJH41D0mAvzQGHyy4RaB+kmVs5e8BS/hw/QyHPtplNYX8JD9N05 mo307EeruQKPiD73yHqR5aRtQobyY/MLlWLcjgrLwKvdNCEo3QvoHclvkN+Q1LJoPgf5 wz+cMOPA4scFXWkiuzwc57I1LzGJV3rGqsW9namc78ak5LxqHbpHFMVzPDu5dqW0au8J NOeA== X-Gm-Message-State: APjAAAWKf23VnrfiLgclyf80kqYdvrLtIHWuS8lO5/CxvsXxY9D58qCE BGqEDfCdhzhCS7My8FFtUdA= X-Received: by 2002:a63:e603:: with SMTP id g3mr17312029pgh.167.1558965883538; Mon, 27 May 2019 07:04:43 -0700 (PDT) Received: from zhanggen-UX430UQ ([66.42.35.75]) by smtp.gmail.com with ESMTPSA id b35sm9951845pjc.15.2019.05.27.07.04.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 07:04:42 -0700 (PDT) Date: Mon, 27 May 2019 22:04:26 +0800 From: Gen Zhang To: mturquette@baylibre.com, sboyd@kernel.org Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] clk: fix a missing-free bug in clk_cpy_name() Message-ID: <20190527140426.GA6078@zhanggen-UX430UQ> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In clk_cpy_name(), '*dst_p'('parent->name'and 'parent->fw_name') and 'dst' are allcoted by kstrdup_const(). According to doc: "Strings allocated by kstrdup_const should be freed by kfree_const". So 'parent->name', 'parent->fw_name' and 'dst' should be freed. Signed-off-by: Gen Zhang --- diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index aa51756..85c4d3f 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3435,6 +3435,7 @@ static int clk_cpy_name(const char **dst_p, const char *src, bool must_exist) if (!dst) return -ENOMEM; + kfree_const(dst); return 0; } @@ -3491,6 +3492,8 @@ static int clk_core_populate_parent_map(struct clk_core *core) kfree_const(parents[i].name); kfree_const(parents[i].fw_name); } while (--i >= 0); + kfree_const(parent->name); + kfree_const(parent->fw_name); kfree(parents); return ret; ---