Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4923930imm; Tue, 21 Aug 2018 03:25:24 -0700 (PDT) X-Google-Smtp-Source: AA+uWPx1fPpc9RDxu1qwWz20jnH7bMtnIEL93ItTJwUE2Z5bc1MS8vHueJoxLLeVMArUBL9OF84P X-Received: by 2002:a65:60cf:: with SMTP id r15-v6mr46628429pgv.41.1534847124572; Tue, 21 Aug 2018 03:25:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534847124; cv=none; d=google.com; s=arc-20160816; b=03uhdlErZ6QJa4gCRYgA4KyFPBIfRNLCL+gP4d8z2EfTcKY8XVKjNnT4ag94DQ/SXh 4tsgKf0ZLEbh4pZcUqpVZP8BzRGyHr/UdsV12s1IvDAmu3kRzps1axa9iPTkdM10iLB6 dG8R9uinOSxNX9PyDOsadpiqBeZQA03Xaa0uzwm+i5HtFgqurqOuShGJzOQmRtwaS26d uR0gIfXR5h/X7gtAcIxn4BQbJSWOkTXhi0bFDPiaU74pfcwBmmPoMuOdqFfTgaylbKOS /ConzuVU40Bd35tSDEg1tUXLn7IX6165w2X0IqGYRQB78ekRD86C3Lwk25M7UTgPrNGM ldfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=A7SN8xpaiDYjY7nCKAQYaLcG0cycQjyB4lVhRiDuUKU=; b=qH8XElDO6zOweqIMHOjOQ8ShV1EUsO8LRtGJDGtUtFMXcKNJu/JjM/0djqWZKUs21v pworp8yEgHSPXnwpRB3kk5Sy9Dpie9yNSfoaNaWbyxcmvCOlpZTpe2TpZlz1k2H4iUER 0kgpXQtnjpn4GK9pM4fai25Sgj2mCxhJ/4kn8PtXiRJ41kDaaIjs2Fu7nEnK8HSNBFhE UCU5XC9Q8krMt3q+7pWuKAcEh8lzY274/Ra6ja5+Q0qRHGBCpilb1VSwWwKSdgF97USZ REndyv0X6aE8EVA7oev/xXRalO5Ns5BJOTui76ztsT8gc+2649JiWWMkPw/Anel5aXwY YrAQ== 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 u207-v6si4054733pgb.640.2018.08.21.03.25.09; Tue, 21 Aug 2018 03:25:24 -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 S1727076AbeHUNme (ORCPT + 99 others); Tue, 21 Aug 2018 09:42:34 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:54851 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726679AbeHUNme (ORCPT ); Tue, 21 Aug 2018 09:42:34 -0400 X-UUID: 27ae6d10cfb94848a986c503d9af19e0-20180821 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1939951892; Tue, 21 Aug 2018 18:22:52 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs03n2.mediatek.inc (172.21.101.182) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Tue, 21 Aug 2018 18:22:50 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Tue, 21 Aug 2018 18:22:49 +0800 From: Houlong Wei To: Jassi Brar , Matthias Brugger CC: Daniel Kurtz , , , , , Sascha Hauer , Philipp Zabel , Nicolas Boichat , CK HU , Bibby Hsieh , YT Shen , Daoyuan Huang , Jiaguang Zhang , Dennis-YC Hsieh , Monica Wang , Houlong Wei , HS Liao , , , Dan Carpenter Subject: [PATCH] mailbox: mediatek: Add check for possible failure of kzalloc Date: Tue, 21 Aug 2018 18:22:44 +0800 Message-ID: <1534846964-13224-1-git-send-email-houlong.wei@mediatek.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch 623a6143a845("mailbox: mediatek: Add Mediatek CMDQ driver") introduce the following static checker warning: drivers/mailbox/mtk-cmdq-mailbox.c:366 cmdq_mbox_send_data() error: potential null dereference 'task'. (kzalloc returns null) Fixes: 623a6143a845 ("mailbox: mediatek: Add Mediatek CMDQ driver") Reported-by: Dan Carpenter Signed-off-by: Houlong Wei --- drivers/mailbox/mtk-cmdq-mailbox.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c index aec46d5..f7cc29c 100644 --- a/drivers/mailbox/mtk-cmdq-mailbox.c +++ b/drivers/mailbox/mtk-cmdq-mailbox.c @@ -363,6 +363,9 @@ static int cmdq_mbox_send_data(struct mbox_chan *chan, void *data) WARN_ON(cmdq->suspended); task = kzalloc(sizeof(*task), GFP_ATOMIC); + if (!task) + return -ENOMEM; + task->cmdq = cmdq; INIT_LIST_HEAD(&task->list_entry); task->pa_base = pkt->pa_base; -- 1.7.9.5