Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1452191ybi; Thu, 30 May 2019 18:17:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfNWyvZB6akyouPWxXN6zOsB24s9fUv/RFRm2Rd8HZ8DVPvnyopc0NXVD+TRTuw7S33LdE X-Received: by 2002:a63:441c:: with SMTP id r28mr3809511pga.255.1559265445128; Thu, 30 May 2019 18:17:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559265445; cv=none; d=google.com; s=arc-20160816; b=yDpp20e5l7hNcrStKk1Vv0s2cGaWacmEv5dxyofAsehTQi+a8TjesGG0vZmbun2Wel sFBloLnmirWNBUZo6u35WwcwlCq3+dPYIx4/+oHhTDsTW0MTOa0NbOywCXPPzyXcz+VU jp8BYTMUrr22DJRk6AvTUjK83dKE5xd5lEi+nHrWyIoC0tFt8+wdIBcXJg9kwMOCpGGW gyveWH4yMiwhB4gBlXWQL+H91wMX/SqCRMOv6/crOhwfn7y4Us+ykajFnlbbQ4XHofVv XdDooY6sOe6LBqzKNOzDvETQaKlY1wqhgJDKo0B1/tU0N5riLnc04XYBwWGMCAaf3+0m TPbA== 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=aQ7Ik+KgWHFERr3hTcmSnIiw5n7Ojjf4YCOd5nZpMSpbakWelCVTLUya/vqactdm2N HoXblN2c4tSXd9ewaOID6TmTGSoyL22dhgqm5u0+ApLqWQsNpAqNwR6HusbkAK5cCf/B njYzvGsVNG4EtmXBfxpjc9rTPs5AK/eFxOOBBOk8NDZmljzsYL0M834ho4B7nj+QXvvA Esm3eM3TISti+hOOwIixN9w28pc4dUrgUciMDTqjPAPsm44Uai6aHbobar99IhrswbGV vLGqPsMUtVcSknLpzUmk1QTlGs61fpmwbH+H3LqyBpYDRss2eChNziY02m6Jcbv3l2x0 swtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qZsN93pw; 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 s13si4331463pgs.446.2019.05.30.18.17.05; Thu, 30 May 2019 18:17:25 -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=qZsN93pw; 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 S1726748AbfEaBOe (ORCPT + 99 others); Thu, 30 May 2019 21:14:34 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:38223 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726430AbfEaBOe (ORCPT ); Thu, 30 May 2019 21:14:34 -0400 Received: by mail-pl1-f193.google.com with SMTP id f97so3279127plb.5; Thu, 30 May 2019 18:14:34 -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=qZsN93pwjg7V6N/NY7PV07aDyLaI9nzUvIhSPYgt/NlMTnkBvCERqLbEfq5iBP+IBx 7h3lx+OJf+SRWXgrQjqfpn/Zk0t9WSh+PrcTZgIz1g3RbmIza70KnUzmY09lodiJRkY5 ZVIhoHB3GUoVdDZe4W7HKGjXjjlDF5lBnFwLnOo+0vzirtByWnCh9Gk994M91ALLhpKG JA/iVZGTNSglz5kYTbjI05UFwWMzI0gtMAbA7nt0d+moAXz12OlKx7SKjht13VTIcx1Y gELxjdvjlKkc3pIqLhO1I26MuoFGV/ci5FX7TFBnvcyMedcDZMiUfeSOeeP/+phsbifx 34Ng== 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=ubFCZD5KwFCEB1f9NIioLr8VUVhvTYgSd0DGDR+XdIyM2z9PqDmU56UZaUoEqv+spR 8PubMVjb6Mj1UraTMMGxaYbmjbXRv3QRomJ+qeNy6+aHzHdB8Yo62zBqO/EdHnLiTQPJ pJ+pysRZnNsWc90rQoXd812C0a+wfP9LtN2ZwaIrbBqfdDvCpii60xAhck9yn0K0aeMh uCV3o8aiOZ31xroQDO6TjBgSfkq640WWPCHmk2NFYov3OwEhrpeS4c61TsIuYV687tXO RCsWNRkoJhr3f6hzaSPNl3TaBHlmyUS4U+D9UxLSdoQLzFxRkOAKLbH1UkPOGuPUCQSh ZrFQ== X-Gm-Message-State: APjAAAUjjqxjg0Igl29euNOcuYYSwBY9fQRRJAEqRopQ4Glt9aBWIT4L GJm38Kefq/uCaSoUbRCwsEw= X-Received: by 2002:a17:902:ab97:: with SMTP id f23mr6500325plr.237.1559265273866; Thu, 30 May 2019 18:14:33 -0700 (PDT) Received: from zhanggen-UX430UQ ([66.42.35.75]) by smtp.gmail.com with ESMTPSA id j97sm3747107pje.5.2019.05.30.18.14.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 18:14:33 -0700 (PDT) Date: Fri, 31 May 2019 09:14:24 +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: <20190531011424.GA4374@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; ---