Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2042945imm; Thu, 21 Jun 2018 06:25:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIVtIzo8aFdsqt8xR8z95IzmGM1K5qght2F/dxLZWC6LM3ngl+NbXpAFqNwDMIvqofAUbXx X-Received: by 2002:a62:1656:: with SMTP id 83-v6mr27440057pfw.61.1529587542465; Thu, 21 Jun 2018 06:25:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529587542; cv=none; d=google.com; s=arc-20160816; b=O0wSStGOCFp86hyghwIDQen+enhRqqRDu6iiX4q4Z1zZvwm8WHoMSnYQ68ofGxFdcM n2BVKxtDWkHP+aOSv/xENmtbJM2ZS3CpfectelA8jmLb5eDkQy8Q2OvxLYuZ8QhPB+Eg 6FTAX02tc1WpJYQ7ndr2MpH/0NwbNDa7/BciOnsYK9Uo9j9a3jgHkmfSNwUTHovZgQvR 6nFoZzbq2vJaGv36Q3BV3vbKN6XE1nlnw2zawCn2k7zvKl0ERSPsiR0TPHoEmbQSQhOV s1xZnhwror1GvTMy0Zl3gPbyFfunSDI10gkIqs7Kiu6qRRW6R4yHjr2JfR3Y6+FUf1+1 49Sw== 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 :arc-authentication-results; bh=exF8xAE1Sb3PhbLe/AwoLkNoLpHxOHoB9KopZ8JOp1U=; b=y+Lox0mWatFkX0YxoZBeSmyf8PTv0GqDvqYsrcLL8NvOvD9ei8QZMMFNJrngl3Hvct xz5YKk9hIiacX5DSQ0t6x5fCiG+oLrZQhZKSWKf9QJ60D4VZvDpPASU7EVJp9DD0aeKu j9rKKRjHqVEZPyza4d0YvPPDPzgpHVN/WS+3GmqVg154VMziPYwZy/Jgza/jlVbVrmQB u7/QQtjUKk2H8YsyTqJnm+WRfMyE2cVSsASwz5gWJNVsj8+WcXhRR2VHC4NSZSHQ1aOc Nk6gjtHyaXu3O6BJ0ym+WqQh87Yi+W6wERx8pxR6HQpyxNJGy31d0zy8q9lXI6+KKJ70 ry2Q== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l1-v6si3888379pgb.187.2018.06.21.06.25.28; Thu, 21 Jun 2018 06:25:42 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933209AbeFUNXv (ORCPT + 99 others); Thu, 21 Jun 2018 09:23:51 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:55030 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932742AbeFUNXu (ORCPT ); Thu, 21 Jun 2018 09:23:50 -0400 Received: from 79.184.254.22.ipv4.supernova.orange.pl (79.184.254.22) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83) id fcbdce66af83b2ee; Thu, 21 Jun 2018 15:23:49 +0200 From: "Rafael J. Wysocki" To: Viresh Kumar , ilia.lin@gmail.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] cpufreq: kryo: Fix possible error code dereference Date: Thu, 21 Jun 2018 15:22:37 +0200 Message-ID: <3263924.Aj9MpNRJPk@aspire.rjw.lan> In-Reply-To: <20180618045523.p5keat3323wymvpu@vireshk-i7> References: <20180614202921.32535-1-ilia.lin@gmail.com> <20180617195842.22818-1-ilia.lin@gmail.com> <20180618045523.p5keat3323wymvpu@vireshk-i7> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, June 18, 2018 6:55:23 AM CEST Viresh Kumar wrote: > On 17-06-18, 21:58, ilia.lin@gmail.com wrote: > > From: Ilia Lin > > > > In event of error returned by the nvmem_cell_read() non-pointer value > > may be dereferenced. Fix this with error handling. > > Additionally free the allocated speedbin buffer, as per the API. > > > > Fixes: 9ce36edd1a52 (cpufreq: Add Kryo CPU scaling driver) > > Signed-off-by: Ilia Lin > > --- > > drivers/cpufreq/qcom-cpufreq-kryo.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/cpufreq/qcom-cpufreq-kryo.c b/drivers/cpufreq/qcom-cpufreq-kryo.c > > index d049fe4b80c4..74b9b93d511b 100644 > > --- a/drivers/cpufreq/qcom-cpufreq-kryo.c > > +++ b/drivers/cpufreq/qcom-cpufreq-kryo.c > > @@ -115,6 +115,8 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev) > > > > speedbin = nvmem_cell_read(speedbin_nvmem, &len); > > nvmem_cell_put(speedbin_nvmem); > > + if (IS_ERR(speedbin)) > > + return PTR_ERR(speedbin); > > > > switch (msm8996_version) { > > case MSM8996_V3: > > @@ -127,6 +129,7 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev) > > BUG(); > > break; > > } > > + kfree(speedbin); > > > > for_each_possible_cpu(cpu) { > > cpu_dev = get_cpu_device(cpu); > > Ideally this should have been two patches as you were fixing two > different problems. But anyway, you can go through this time. > > Acked-by: Viresh Kumar Patch applied, thanks!