Received: by 10.223.185.116 with SMTP id b49csp2231342wrg; Thu, 22 Feb 2018 10:10:04 -0800 (PST) X-Google-Smtp-Source: AH8x225eCyelLVHalvmZwKCrWIQbScgLqiuL9tLeU9CjszGc0gVCpNA/yC1puAhegPyYjZTZ2O0t X-Received: by 10.99.66.135 with SMTP id p129mr6455337pga.220.1519323004684; Thu, 22 Feb 2018 10:10:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519323004; cv=none; d=google.com; s=arc-20160816; b=P6GXvOCMIqHnfiEJaD0ZWJAMPfLkyzFC6kvmyJnu6lwpeD8IQPHrwAL0t2+11Ay49F qLunn6rD0fcicT/eScgiTsKi7cBhBMHS6pt6BJFq85SKYe9LHXasUgeBetCqMFM5KFT9 idHkMwSyPYSEDgQnahMtAKN+qulfO0m5hgI8fItXHgHwXZe7f4aIteowbwo6txXFcFVn LNKpDl7BiQoNVwymTv6W+7XfcMh51nDwlgfCVi/MkWnH8Rr0wz3tSn/ElGiqwNguh83l iel5FysEvzVhvJKv6D0B3QozfiDfJabS6y4fIID1Fsp4XBlSkt7q+ffkbupLIQN14Th7 Nwog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:arc-authentication-results; bh=OO99COB2mnkb+8LEGa1sN8TAt55UU0xd95FNrLfDwSs=; b=tDQEYrRwqcmkrNLkG1bsfYZbo0rEqAVpk0kmPze2zDvgzqAgPs4or1EpL8lSUtzZkc Z+6qNm261yzGKq1/05mx8zA7zfx6P6Ks4GrMzxuAg66QJFc+fo0IqG2Wb4TxT2rxBxtU KqMJsOXsT9c2mV5XWxK0wg858JDfniqOUONAhwm5gapVXGtupuGB1XndNeyEI8hMws+h gje6EbPxZrUT1GyImClKgt91P/lf3IkjFz85qS1ZRAV/wA32pcwZjQo6iPIJenDuk3BF eqSTy2+IgGYYk5ymHlLwZzmS1kFf8UPAUilR1cutBG1bWZju6B7YvJcWCr8lKCD0q5eW nVtw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m189si377968pfc.410.2018.02.22.10.09.50; Thu, 22 Feb 2018 10:10:04 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933670AbeBVSJA (ORCPT + 99 others); Thu, 22 Feb 2018 13:09:00 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:55278 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933504AbeBVSI7 (ORCPT ); Thu, 22 Feb 2018 13:08:59 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1eovIb-0005dL-OT; Thu, 22 Feb 2018 18:08:53 +0000 From: Colin King To: Ralf Baechle , James Hogan , "Steven J . Hill" , David Daney , linux-mips@linux-mips.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] MIPS: OCTEON: irq: check for null return on kzalloc allocation Date: Thu, 22 Feb 2018 18:08:53 +0000 Message-Id: <20180222180853.11505-1-colin.king@canonical.com> X-Mailer: git-send-email 2.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King The allocation of host_data is not null checked, leading to a null pointer dereference if the allocation fails. Fix this by adding a null check and return with -ENOMEM. Fixes: 64b139f97c01 ("MIPS: OCTEON: irq: add CIB and other fixes") Signed-off-by: Colin Ian King --- arch/mips/cavium-octeon/octeon-irq.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octeon-irq.c index b993d9f2c9b9..203e1d2a56d5 100644 --- a/arch/mips/cavium-octeon/octeon-irq.c +++ b/arch/mips/cavium-octeon/octeon-irq.c @@ -2277,6 +2277,8 @@ static int __init octeon_irq_init_cib(struct device_node *ciu_node, } host_data = kzalloc(sizeof(*host_data), GFP_KERNEL); + if (!host_data) + return -ENOMEM; raw_spin_lock_init(&host_data->lock); addr = of_get_address(ciu_node, 0, NULL, NULL); -- 2.15.1