Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1614002ybv; Fri, 21 Feb 2020 00:18:27 -0800 (PST) X-Google-Smtp-Source: APXvYqzIwa+BeL0yd4YdCcZ0aDYEGOqGpzFtABDFuJsPwyGFkSRpifM1yK6IwS23Qha4LitXc+8x X-Received: by 2002:a9d:5888:: with SMTP id x8mr25981021otg.361.1582273107612; Fri, 21 Feb 2020 00:18:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273107; cv=none; d=google.com; s=arc-20160816; b=TRLBkR0b5djFWtWNFEVw9WR6Vcn7LJNJLe+1P4inEs1apJiPxaopt7lHre7h5L0S6y N+eY3m6T24J6npmCz14FiOjPLkvEb7OSyo4D/ftgmf0cVX3TPpF1/wbv4R7ADKwMUFzb XsrMfOTq3g+f6xvSh1gpkWxOjjMES53fYSzcdoV8Ju3GFHpSrIPa1pfwppyJQpB+K4+w eoTUUCuE023zgts7lSCdTQdWJen+b48kmRLXaO4s8zWik9JU1LAIeSPpSPnZIRo9eMH7 cZI0PpoSE93XnJc1he+mTXFG7M57jLLjtEm5g9HcYZ5CAHYq33RPu4dgiWOcTbQ+f95s S8UA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZvdGFZzzqJuDwEfOPVtOXuZ1CDL8FTXlRuu8d73xDTg=; b=J5q24y/f+xDMK3DOP9pkpYHzxKaGkl7Snfkklqbc88ilFKXQQamDVktIHoty+lt0+h cPn4bM+VUBrPEew+xxnYeZC0bQiUwtnQDzQMZTiZIQnHHHxpg4aN/K6usdf/VCGvS0NI s6MDcGYTSYJn4JPyvSkwJIlS+XM1pJK7+NSPH1yVUBRoQlnneddMqaDczRCYoj50NseX JP8rWiMW8kW5M0avpGhqZjJS9O5/TEdHfOVua/2/S71tIP/5F7j63WuiU80OjIuSx7UU o97JS6r6JSWzcoXvn0YT/q+2uXvv1rLmT+uWRTePVNzv1+iBXyYdvZvaELwFGH5iGM04 EeEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EKiAagVb; 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 e23si468072oie.105.2020.02.21.00.18.15; Fri, 21 Feb 2020 00:18:27 -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; dkim=pass header.i=@kernel.org header.s=default header.b=EKiAagVb; 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 S2387695AbgBUIRe (ORCPT + 99 others); Fri, 21 Feb 2020 03:17:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:55072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387686AbgBUIRd (ORCPT ); Fri, 21 Feb 2020 03:17:33 -0500 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 E0CB92468C; Fri, 21 Feb 2020 08:17:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273053; bh=KNL8q96VW054YfXBZfeHGlfLCZJ5LleWzR+KoB/9j4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EKiAagVb9r91HEr065nbHOYlHW1apmxv3xAtPhrLsaAv24H4QZUcvR/BBabMmPkTq Onu8/2FN4a01Pq0gZgjc6sUU91qXOKeKC0H8Ly4wRu34KarP8KAWVQ8IxVIKYpXuUd OMVR95YdRtdu5i/CMZuFv2X4tQAkKivg05fE9oDw= 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, Sasha Levin Subject: [PATCH 4.19 029/191] MIPS: Loongson: Fix potential NULL dereference in loongson3_platform_init() Date: Fri, 21 Feb 2020 08:40:02 +0100 Message-Id: <20200221072254.750279305@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@linuxfoundation.org> User-Agent: quilt/0.66 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: Tiezhu Yang [ Upstream commit 72d052e28d1d2363f9107be63ef3a3afdea6143c ] 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: Sasha Levin --- arch/mips/loongson64/loongson-3/platform.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/mips/loongson64/loongson-3/platform.c b/arch/mips/loongson64/loongson-3/platform.c index 25a97cc0ee336..0db4cc3196ebd 100644 --- a/arch/mips/loongson64/loongson-3/platform.c +++ b/arch/mips/loongson64/loongson-3/platform.c @@ -31,6 +31,9 @@ static int __init loongson3_platform_init(void) 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]; -- 2.20.1