From patchwork Sat Mar 24 15:52:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 10306091 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 5DA8560385 for ; Sat, 24 Mar 2018 15:53:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A8C2292D9 for ; Sat, 24 Mar 2018 15:53:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B49A292F8; Sat, 24 Mar 2018 15:53:05 +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=-2.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM 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 015E1292D9 for ; Sat, 24 Mar 2018 15:53:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752084AbeCXPxC (ORCPT ); Sat, 24 Mar 2018 11:53:02 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:36935 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751891AbeCXPxB (ORCPT ); Sat, 24 Mar 2018 11:53:01 -0400 Received: by mail-qk0-f194.google.com with SMTP id w6so16002652qkb.4 for ; Sat, 24 Mar 2018 08:53:01 -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; bh=zwBvu1Hmk4oyH7H09uC6qVVcF7uC3J8C/zKiWCA3pYE=; b=XUJcBBJ2HiXiKFFf0P4rl/lSs5SK4wb5m6XIZLM+tPp2gYZiMN1/YOOUTm5suEPOEc USmJJg7wd9r4UQFFIkN3BMFd+39VhvCZmiLQgkp3+lQCEaI2SwUX3YcCF2bfqIn94l22 dx5Avzj9r5VYch5y270Jzb4fm17YbNLywYHaNgyH1wXUUHEDslr8IhJ53ZN9uTnD4S48 CE0GGQJWcIV1hL0Ua0ikRpaby6BFX/zzqV+gfnvxwO2JEIeqHBJzDcgYMfEDnW75LFwF 6Db68CHyVXkPFaxMGFzLXJC1qojMu7+7whKo+E9QA7BIQAciZB/Zs/RfPSgIWpHYdspK P4Iw== 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; bh=zwBvu1Hmk4oyH7H09uC6qVVcF7uC3J8C/zKiWCA3pYE=; b=sH7f+2390RUJhnDRK+wJbUKUVm81TXJ4DMdWI4anY2tLrRa7Z8WDGiIRqUMW4TOk5+ ngmvmwmi8N/e5mLmF90l0dkF2BGd9GRB748hqgqNt7IMW8fuaRa2oG1Q5wdb/Ep9PuC4 WMmBwS0JbPVFZNkMD6QdusF+FpDQCoprBb4yBXGZfqKGmxoqe1ywGjyMelHoTGEp/dpf 4yF5+wrxDwCPz+/MZxY3q7K+Z846ra7JcK1czxrmG7WmEUhrBFCV+8eSIB4yhbc/Fm4F m03455OQbZAorUB6YobPoTiwAHHOp3ky3tCA05B8sW79zrGh4Ieqlucw0q1PVyRU0NAa a6sg== X-Gm-Message-State: AElRT7EGlYiMQGQ8V0ueisFF77KYEPlfvinDfGJs8HQ0fnPQJiSNx16F RmJCp4libF9SKYX2cnJ5yTM= X-Google-Smtp-Source: AG47ELvfgFQ6SJhQn0KFy7WquC+R4vDlT7e+9UCAKnoiHWdo94ukTgFsyBSNPw/CdLuxJjZJXXQbVw== X-Received: by 10.55.191.1 with SMTP id p1mr46616438qkf.97.1521906781126; Sat, 24 Mar 2018 08:53:01 -0700 (PDT) Received: from localhost.localdomain ([187.180.181.214]) by smtp.gmail.com with ESMTPSA id c5sm8485964qkf.93.2018.03.24.08.52.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 24 Mar 2018 08:53:00 -0700 (PDT) From: Fabio Estevam To: rjw@rjwysocki.net Cc: viresh.kumar@linaro.org, ego@linux.vnet.ibm.com, linux-pm@vger.kernel.org, Fabio Estevam Subject: [PATCH v2 1/2] cpufreq: powernv: Check for devm_kzalloc() failure Date: Sat, 24 Mar 2018 12:52:38 -0300 Message-Id: <1521906759-6856-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 2.7.4 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: Fabio Estevam kmalloc() may fail, so we should better check for error and propagate the error in the case of allocation failure. This avoids a potential NULL pointer dereference later on. Signed-off-by: Fabio Estevam --- Changes since v1: - s/devm_kzalloc/kmalloc in the commit log drivers/cpufreq/powernv-cpufreq.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c index 0591874..4ddfec9 100644 --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c @@ -329,6 +329,8 @@ static int init_powernv_pstates(void) revmap_data = (struct pstate_idx_revmap_data *) kmalloc(sizeof(*revmap_data), GFP_KERNEL); + if (!revmap_data) + return -ENOMEM; revmap_data->pstate_id = id & 0xFF; revmap_data->cpufreq_table_idx = i;