From patchwork Sun Jun 17 19:58:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Lin X-Patchwork-Id: 10469207 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9BD2A600CC for ; Sun, 17 Jun 2018 19:59:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 853F72888C for ; Sun, 17 Jun 2018 19:59:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 636FD2889B; Sun, 17 Jun 2018 19:59:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 550702888C for ; Sun, 17 Jun 2018 19:59:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933225AbeFQT7h (ORCPT ); Sun, 17 Jun 2018 15:59:37 -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-Google-Smtp-Source: ADUXVKJWGcnW+kz6Vo0Cg7HfF8/2K+u92V5yL1mmnWWnR0Nt2ULD5WHY+Zg2UW6afxbia46xlwnqHg== 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Viresh Kumar --- 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);