From patchwork Sat Mar 24 13:49:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 10306049 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 90641600CC for ; Sat, 24 Mar 2018 13:49:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80DB6292C2 for ; Sat, 24 Mar 2018 13:49:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71C62292C4; Sat, 24 Mar 2018 13:49:54 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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 E3137292C2 for ; Sat, 24 Mar 2018 13:49:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751999AbeCXNtx (ORCPT ); Sat, 24 Mar 2018 09:49:53 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:33066 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751930AbeCXNtw (ORCPT ); Sat, 24 Mar 2018 09:49:52 -0400 Received: by mail-qk0-f196.google.com with SMTP id d206so3456138qkb.0 for ; Sat, 24 Mar 2018 06:49:52 -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=D1gah1jlExFIdaO3ZPW4aSHUK5tM3p1UbsE8sFc7UGQ=; b=d7pf/hdhJfciC4En7j+uyz4CFg19RzMLsZ6HZOBDijs2cZ0m0mmmlFA4t17Jrks5XA Z6vfeeg8dH7hdrTo7c3RkDY7lCLQuf8mIiaUe6tdXHZCdS9g6HvjT2xG8WtE8xdkG+NA +HggSRhuTyFDV8GYouhQTRVDGVtT+Ar+h6BhK9jj8R1nmk4WtaKMU/5Mg/J+Zd0Dieck YxjQgeawicocqdJtRzoVnaQM/dQ5eEfoIrsIea1WOaffGWJtL/JssIN/gWQb0OlfqD0r 3gc1wzErXqO5HOlMHyhL3G9YOTsfaUaz4VItK/JyQ5+7n41JxIkKkTxwNDzbH/IfLEoI 7U/A== 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=D1gah1jlExFIdaO3ZPW4aSHUK5tM3p1UbsE8sFc7UGQ=; b=VqR/GW8KUjUyCSiryZDpptlPNEBsIi8DhBpnqLS2QBGMgl2KoJzvlkds3tXeeLFUbV FZbroIo6iDOPdNSAU25gsF4Ku3doT3Z/WoDZKKUxvFawGxBH1LXxAJ3kQXrr9Qu4D4q/ wQnJSllZPP6s8WYGmVZJuuhHCSfALeQtkevCkRu0drdvqa2uUtq62DNdg/hu+Mysk9eP saIBrKwcb/Q/ygooil3eaTa3RzpRBrnXC/Xm7sjQDL+iUlSg2Qdk3NJp+KirCiNsUyDv 8hfBablUZ8+mefrzbJ+EXvkDK/06+Qb4rwEqSZ1IcY50+wTOP5VGnPeSDmbiCTMnbNm8 Wniw== X-Gm-Message-State: AElRT7FHUF3pjfFF2jAKNQac0U4PQWkpmh77k0LcQEmPDvULIL0b8tn8 BFuCu13kM8leqZMm996Tq2k= X-Google-Smtp-Source: AIpwx48Ky/O3q4SbnY7mJbtr7n76G0nS4Cx5U6uZrrJyJ4XeoSQ+DEBxWayRV3dQitKA6zOOUS3N2A== X-Received: by 10.55.103.215 with SMTP id b206mr15332855qkc.121.1521899391742; Sat, 24 Mar 2018 06:49:51 -0700 (PDT) Received: from localhost.localdomain ([187.180.181.214]) by smtp.gmail.com with ESMTPSA id d184sm8711412qka.68.2018.03.24.06.49.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 24 Mar 2018 06:49:51 -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 1/2] cpufreq: powernv: Check for devm_kzalloc() failure Date: Sat, 24 Mar 2018 10:49:34 -0300 Message-Id: <1521899375-24335-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 devm_kzalloc() 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 --- 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;