Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3173625imm; Sun, 17 Jun 2018 13:00:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL7tQUlJDp7UqZtCNBEEdo1ak2fEsw1A9cdYbfDbu575gu2jBv8S8vvrfgUrRi5Vl4BHfJu X-Received: by 2002:a65:40c3:: with SMTP id u3-v6mr8730056pgp.356.1529265618569; Sun, 17 Jun 2018 13:00:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529265618; cv=none; d=google.com; s=arc-20160816; b=IpfvxR55uLE/D9yS18cHM+xzNQeGZlUoYTkA9xM5x5OUn/j5KgQYmBQImeYgoaHmKV MVfmoEFNAzllxxhW9/r5BOm4+0ewArJUiBlF1MRMvniAZR9TVU0Bao+Tg+2p4s5xTibR U/3GaBC7biQT2hkEqHOzDELYVkT7I6KhqEHhVYKB9X9P/NG+tq38zQ8Z7MlbOzrdxPoN KCpeRSujD+tgQzh61QBgLJRAwjXo0IpGpgqGv2U4cazKMBcCb929Es+z79C3Jo8gthAl TbLtYX9SFfL44LgcVvHKyZGb8CAG6wIMxhVhnrcZnP6vAWOtIiWJp4yYKK4JB5DjyDMu wfuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=UHsZZyNUXqt1XAGH/gvRFV868PDA/0BUanBpRgvjugQ=; b=i6wi6OMKoN9o3RwBgZJ6qipSdg+NZmsEQI6kcGJW5b8K5U3jxpBmnHUTppFpJDVwmc 3KbKrbQOL81fP48WI//sc6ikHhmkGqiBWJTSgFH1A0UIME+K+NRraf3FBIk9yjDJt8X9 M9z0LESKAzu+NgJZMUcv/ZQAXJILT+Aan/zGTd1I1Rqk+8ZxJBk1qp5crgIceYhBHt33 CV5k15FG4cf6LAQDYBuqbMpr5tcJ1yg7E6Hsj3z9jqPiV6mUyqYh9GrOSwUbrN/vR/Y/ tU+x8qk3AQ3ZmDZjCbBqwfQt5h3h4PtqyTCUiNrILJVfAobHrvPwJQk6naTuuSSrr3sQ ukvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WeZhyGHi; 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 k3-v6si10692484pgq.28.2018.06.17.13.00.01; Sun, 17 Jun 2018 13:00:18 -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=WeZhyGHi; 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 S933747AbeFQT7i (ORCPT + 99 others); Sun, 17 Jun 2018 15:59:38 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:51177 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933204AbeFQT7g (ORCPT ); Sun, 17 Jun 2018 15:59:36 -0400 Received: by mail-wm0-f67.google.com with SMTP id e16-v6so10799524wmd.0; Sun, 17 Jun 2018 12:59:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UHsZZyNUXqt1XAGH/gvRFV868PDA/0BUanBpRgvjugQ=; b=WeZhyGHi7eNWmj0S5t7r+CiL+230B6/nf1qKgcZd2DIxwnnsDW6ncX6N4dLKAXzdfK adBlcTXrqK+QFNGTEfT22TcOXW5vpf4GQ90BbLGzzt3SmAQNYtZ0u+2iwYTDAPB3SKDb d0lOgbDCgbJRGZQHJokVJC/XwHkjZt4IEUus056txCquAtVam6weGF0q+RlVqZTsIhHQ /VQlH3LGdxOvejj2CxDJoFWzbi2NPoQscoHpbJ/DIbrO8DtVfHny84iIIlUBR4x7AFj5 LxB1HCcOyQt7PaydIYRePSubOGJb4CLKJHO2wcu51qCEJ7eep31ZSHj4usIVLUBH8tq+ o7kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UHsZZyNUXqt1XAGH/gvRFV868PDA/0BUanBpRgvjugQ=; b=VzPXz3M1ZQEt/oGbcl3pfly9U1qhNauZ6NNOdSbdhcvIE8a7NakpXcR2La65bRAiw8 nfnkcaphGRrQJWvbbicDJZRdL3tiy3imC96NzlTsxwEHBvpZPjKIYkbsPaUkk6B/PfMc Odlog5woQ6Bd3Dbd9hk5X71wtrQuLjxN1HezlpeE4VVQqmacrBTO5iBqsxoHDpcy+NDs N7gODopBuE5hy2I1Oqxu2nT9YaCJKSopXGLg90xygj8Y9zqJk3ORYHF66BhclOLnxx6j ko1uPQempGf75buTzcBhIi5pzoQoo8b3UCMTCz8ByDhe9mu3t3qmhJiILBy9lAyR/bud tKkQ== X-Gm-Message-State: APt69E0aMGcFhcIPyA+pXgdXFSnFIf/Xr+p+g/2LnKVRX+HqFMUt09/5 1b9Ra4jWE7zvG4e7UqZZB2mlWXy0 X-Received: by 2002:a1c:9c0b:: with SMTP id f11-v6mr6526212wme.148.1529265575159; Sun, 17 Jun 2018 12:59:35 -0700 (PDT) Received: from gcc67.tetaneutral.net (gcc67.tetaneutral.net. [2a03:7220:8080:c00::1]) by smtp.gmail.com with ESMTPSA id q17-v6sm14125392wrr.7.2018.06.17.12.59.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Jun 2018 12:59:34 -0700 (PDT) From: ilia.lin@gmail.com To: ilia.lin@gmail.com Cc: "Rafael J. Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] cpufreq: kryo: Fix possible error code dereference Date: Sun, 17 Jun 2018 21:58:42 +0200 Message-Id: <20180617195842.22818-1-ilia.lin@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180614202921.32535-1-ilia.lin@gmail.com> References: <20180614202921.32535-1-ilia.lin@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.11.0