From patchwork Thu Feb 13 15:20:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 11380589 X-Patchwork-Delegate: paulburton@kernel.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E7367139A for ; Thu, 13 Feb 2020 15:41:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C6C4724688 for ; Thu, 13 Feb 2020 15:41:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581608460; bh=PiBdcD+Bje6p3RdBSrjXgWJm4Gd4Cq0tAJ6WKxdJb8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=1jpUgmeNuUVwCy9jyy4+y1tKYcbWKO/ntKt7Hwh0iOd2E29/hN5JxKAq2irw+VTX8 d1ZroZRgTourAAFpcb+Dqj6HDTVtZ9Nge0JwBA8tU+Iv0PZk+iCGWp88q4MId+O1tc 3mw/7xWnk0pGmHuNfNkZm/s3Vdx/YygueOL7zoXY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728618AbgBMPkp (ORCPT ); Thu, 13 Feb 2020 10:40:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:56400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387749AbgBMP2i (ORCPT ); Thu, 13 Feb 2020 10:28:38 -0500 Received: from localhost (unknown [104.132.1.104]) (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 500812467D; Thu, 13 Feb 2020 15:28:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607718; bh=PiBdcD+Bje6p3RdBSrjXgWJm4Gd4Cq0tAJ6WKxdJb8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dPU12V8meH2xefUYncCHTXDHRW95IPJXc4tJZtL6sUSXuTR/rbpB83LM04i/pZvou +zt/WxmW44KsEAM7DXrlcG/mBJ94Y2xY3I5orGWPyrxEQ4khjiESpbwAhZKQ/C7E5e vGGb8kD6GWp5QzCjJ/R++ONL5jXOmPJU36zxsWBY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tiezhu Yang , Paul Burton , Ralf Baechle , Huacai Chen , Jiaxun Yang , linux-mips@vger.kernel.org Subject: [PATCH 5.5 052/120] MIPS: Loongson: Fix potential NULL dereference in loongson3_platform_init() Date: Thu, 13 Feb 2020 07:20:48 -0800 Message-Id: <20200213151919.611428309@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151901.039700531@linuxfoundation.org> References: <20200213151901.039700531@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org From: Tiezhu Yang commit 72d052e28d1d2363f9107be63ef3a3afdea6143c upstream. If kzalloc fails, it should return -ENOMEM, otherwise may trigger a NULL pointer dereference. Fixes: 3adeb2566b9b ("MIPS: Loongson: Improve LEFI firmware interface") Signed-off-by: Tiezhu Yang Signed-off-by: Paul Burton Cc: Ralf Baechle Cc: Huacai Chen Cc: Jiaxun Yang Cc: linux-mips@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/mips/loongson64/platform.c | 3 +++ 1 file changed, 3 insertions(+) --- a/arch/mips/loongson64/platform.c +++ b/arch/mips/loongson64/platform.c @@ -27,6 +27,9 @@ static int __init loongson3_platform_ini continue; pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL); + if (!pdev) + return -ENOMEM; + pdev->name = loongson_sysconf.sensors[i].name; pdev->id = loongson_sysconf.sensors[i].id; pdev->dev.platform_data = &loongson_sysconf.sensors[i];