Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp282450rwi; Sun, 9 Oct 2022 23:30:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4iwmT1JM+Zw6ceqG/3fJGjzkh8wYMt/Q0YCN3cMymOH/K+qm/NoZm+Uuy/gc0iKd9j9/eR X-Received: by 2002:a05:6402:2989:b0:44e:90d0:b9ff with SMTP id eq9-20020a056402298900b0044e90d0b9ffmr16260359edb.110.1665383455363; Sun, 09 Oct 2022 23:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665383455; cv=none; d=google.com; s=arc-20160816; b=DiEJ4YYQfgo8UIK9nyA8Ut9Jg4xstiVKDPlb4lsLKC8DBiox5YVOMuSpyK4k58OmoO 09LWv2oGj4QVg9R823Io8QgGin8LzN0208+UFCldXP9iiJljl6Tjr5XX4Y8HSmkMt0L+ x9aDNK1ivgMAp3tp0/A8pOuTbpUo1f+oYBvsmmjDyOGVQ9Wa/movjsyJsI5jf76a8r5c /KP4rTRHAO/DLID3KOXelHHV4r2b2r8hi2r9WkpDWIUIVU0/MUwIHWNcLG1pF1Iq7nxt k1ycR2r+nsd3C5r40ZhZNb7BSw+tqE9FlVluoyVrrYYfBt1cQWcSEXSoLloWEyBme+s4 +UVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KuJs/6I+cN8TE2/6QkPMYCE4khGiwZOavYjTwbehxuU=; b=Sd1CZQBLt30LgSNmLBykpSezZgSuHZXhRvUwNkI9XSdLD2KESdEuR3QhPZAaCLYS27 /ph/UFwr8mhMDAQ+TO0NeVLcVtUEqVj8xC4xDAVYzqQQnTvPlQ1SCF+LdRRzY6f7z4N0 jTaHqOZM4+LA7nJFMx8i6YQHNBa2S9hvC9zuIrzsuCB7xdOuikyYJyqu9qN7MIdz+sSx 9BavpdbA+7qwpzeLHdJ2O3Q3LH5xx88fYerEY9uKhXjClUwScmT++p6J9xiukjCRT7tI ytd/hTwkhKJZ3uRVnA1/Jd3nfocUcuEcCLsd0E3/Iot4JIgTYpn6nSsuPqo/S946hzYN Boew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oJQSUhOY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h16-20020aa7c610000000b004597db487cdsi8217855edq.604.2022.10.09.23.30.25; Sun, 09 Oct 2022 23:30:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oJQSUhOY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230464AbiJJFzo (ORCPT + 99 others); Mon, 10 Oct 2022 01:55:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231379AbiJJFzi (ORCPT ); Mon, 10 Oct 2022 01:55:38 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B77A81C934 for ; Sun, 9 Oct 2022 22:55:33 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id b5so9490976pgb.6 for ; Sun, 09 Oct 2022 22:55:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=KuJs/6I+cN8TE2/6QkPMYCE4khGiwZOavYjTwbehxuU=; b=oJQSUhOY41s4B4a5RIRgnQyLQDX5ZdWQabFA8tjd157D0kcEfoz+mrJb02795fSz1U v/8YOvuNw/4ZwwhOGH0rnT97Hzbeu2OUgEC0eZNRVtrHeXAjlxc9WVOcxeALpumO4Swi yTuk7U3DJQop54GqVbmbHnmKkFSw/aBhpucDHzb5d9IjKGnX3LUSzqhgSkvWLdggFpei wiFIAH+ABO7JL6Sr+ALGdUFC15iNsx2qYJJsV0dZqp4L3OrbJEmGPjgZV1+4eBBQFnoN TcEk0KNUxWAMX1SBlHLKN7gybqOQPMReYefd+Sgo/QTTQx/Nn2idmjhXLmzbkmZSaxNL nWew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=KuJs/6I+cN8TE2/6QkPMYCE4khGiwZOavYjTwbehxuU=; b=3iDv14hTj+CEtF3iAUt1ytIama8MHbuGRn3e8nctt+r1IBX6oWGdEW9b42POKr2OjO W64EcAGHTQmK0RaWDr56y3cOLcAS8i9Mhe4lgsHTsSWcVnZdbVRX0xUWfFjFuQqz/0sQ O8I2hCq+954EStA+nMgJEY0wmO+sktmBP160IKxH7cK3zKGQrPbjUKnL1QdSvVQWH6By /FfNfRggxLw/5e1fjxzjS6hJpn1NKR1+zRw9TIooWp6rA/Alfg4rXgcuWEKlJctXBiMc WIywRDzJFIx17XV4gliZqZZ9WX/H0C7YHnPCRw908wGJ18huiM5bjsrfHnDf3nuM2I2t tkWg== X-Gm-Message-State: ACrzQf2OFqUv6cpxqTztpOHjLQhe5TwTSXrBbaD/bebVW8bOXBBYp8Ec 2QbhnYB8TCfQoqJBV49TAux6FQO1nYEXjA== X-Received: by 2002:a05:6a00:1814:b0:563:6bd7:f9e0 with SMTP id y20-20020a056a00181400b005636bd7f9e0mr2553668pfa.33.1665381333058; Sun, 09 Oct 2022 22:55:33 -0700 (PDT) Received: from localhost ([122.172.86.128]) by smtp.gmail.com with ESMTPSA id a29-20020a631a1d000000b0045c5a749a8fsm5410093pga.61.2022.10.09.22.55.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Oct 2022 22:55:32 -0700 (PDT) Date: Mon, 10 Oct 2022 11:25:30 +0530 From: Viresh Kumar To: Fabien Parent Cc: ilia.lin@kernel.org, agross@kernel.org, bjorn.andersson@linaro.org, rafael@kernel.org, linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] cpufreq: qcom: fix memory leak in error path Message-ID: <20221010055530.2mf6lq4mn6zfdkzt@vireshk-i7> References: <20221001171027.2101923-1-fabien.parent@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221001171027.2101923-1-fabien.parent@linaro.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01-10-22, 19:10, Fabien Parent wrote: > If for some reason the speedbin length is incorrect, then there is a > memory leak in the error path because we never free the speedbin buffer. > This commit fixes the error path to always free the speedbin buffer. > > Signed-off-by: Fabien Parent > --- > drivers/cpufreq/qcom-cpufreq-nvmem.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c > index 863548f59c3e..3bd38acde4b9 100644 > --- a/drivers/cpufreq/qcom-cpufreq-nvmem.c > +++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c > @@ -213,6 +213,7 @@ static int qcom_cpufreq_krait_name_version(struct device *cpu_dev, > int speed = 0, pvs = 0, pvs_ver = 0; > u8 *speedbin; > size_t len; > + int ret = 0; > > speedbin = nvmem_cell_read(speedbin_nvmem, &len); > > @@ -230,7 +231,8 @@ static int qcom_cpufreq_krait_name_version(struct device *cpu_dev, > break; > default: > dev_err(cpu_dev, "Unable to read nvmem data. Defaulting to 0!\n"); > - return -ENODEV; > + ret = -ENODEV; > + goto len_error; > } > > snprintf(*pvs_name, sizeof("speedXX-pvsXX-vXX"), "speed%d-pvs%d-v%d", > @@ -238,8 +240,9 @@ static int qcom_cpufreq_krait_name_version(struct device *cpu_dev, > > drv->versions = (1 << speed); > > +len_error: > kfree(speedbin); > - return 0; > + return ret; > } > > static const struct qcom_cpufreq_match_data match_data_kryo = { Applied. Thanks. -- viresh