From patchwork Thu Apr 16 13:23:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 227916 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB8A0C2BB85 for ; Thu, 16 Apr 2020 13:32:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9041E2227E for ; Thu, 16 Apr 2020 13:32:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587043951; bh=sPrl9R+yoAc0NrziY7jtHcAjfyMMgN98O+1GI2m295k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=jDYLQm3ITLcfTAs9kvYvEXPd76+nw38hk7Eu0xa7wpb2xpOOjYm7cksaQca8JEEvN RS6PKlIOupWzggIL7mpV+R4Z0PWnKJkO4fyxySOzS4lhYp1QtlDr6qaqcZYIGpxUD4 SCknxEU/6IRL8CGQi1Ogum/Q9Iyhoh/201daoZbw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2895524AbgDPNc3 (ORCPT ); Thu, 16 Apr 2020 09:32:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:41094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2896304AbgDPNat (ORCPT ); Thu, 16 Apr 2020 09:30:49 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C708C208E4; Thu, 16 Apr 2020 13:30:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587043849; bh=sPrl9R+yoAc0NrziY7jtHcAjfyMMgN98O+1GI2m295k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hCT+5IK6qLY1v6AJbD3k9xnadXfpvbRAcz3gMK0GAjGJKKwO/eT0kw/9A71IikKB3 x9+ElEzi05ks4KyBX8vjEOZsj3X9JGwuZy/lwuAqHFEAs1clcolqdfvOHicf2NJIk4 aXr17cRNfOaT/r2geKyYVU1k2ycar+Ot8YkjIa34= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" , Thomas Bogendoerfer Subject: [PATCH 4.19 075/146] MIPS: OCTEON: irq: Fix potential NULL pointer dereference Date: Thu, 16 Apr 2020 15:23:36 +0200 Message-Id: <20200416131253.199088941@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200416131242.353444678@linuxfoundation.org> References: <20200416131242.353444678@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Gustavo A. R. Silva commit 792a402c2840054533ef56279c212ef6da87d811 upstream. There is a potential NULL pointer dereference in case kzalloc() fails and returns NULL. Fix this by adding a NULL check on *cd* This bug was detected with the help of Coccinelle. Fixes: 64b139f97c01 ("MIPS: OCTEON: irq: add CIB and other fixes") Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva Signed-off-by: Thomas Bogendoerfer Signed-off-by: Greg Kroah-Hartman --- arch/mips/cavium-octeon/octeon-irq.c | 3 +++ 1 file changed, 3 insertions(+) --- a/arch/mips/cavium-octeon/octeon-irq.c +++ b/arch/mips/cavium-octeon/octeon-irq.c @@ -2199,6 +2199,9 @@ static int octeon_irq_cib_map(struct irq } cd = kzalloc(sizeof(*cd), GFP_KERNEL); + if (!cd) + return -ENOMEM; + cd->host_data = host_data; cd->bit = hw;