Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp925333imj; Sat, 9 Feb 2019 10:56:53 -0800 (PST) X-Google-Smtp-Source: AHgI3IbpLjaR9cs3P1cpoVGbngeVtLErQS9M+STb1WNna+8Wa8FxeuKI1YCM8sboGdFwZbhrATCY X-Received: by 2002:a17:902:b118:: with SMTP id q24mr29869980plr.209.1549738613773; Sat, 09 Feb 2019 10:56:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549738613; cv=none; d=google.com; s=arc-20160816; b=vAI1O3kqwy9RWY55YNDIx59eacLVbah4p7+GqfmNRLjQyaAce6iKI2naKh7a3T0C2o VHRjYgXFKxKRTi5DMr3A113uXsRrcb/ngBuvzHsFwdGibplP2/J/BIFzeiqH4D/oJXm+ eZaAcPqOT4x2N91nV1G7rLzWnMxGSxXpiTsYY+xh3ggGfo2xUbcqmT5ZVthHdSs9vh9A 9KJC7Zj/HU+lMzZENkuCB7yWi/F8+fo9FpHfmUsqIf+i9wvXmCEghmV6A6Pay4N0Skeo QLr5zihzkFgWzftZT8tYO/ldSN/hVG5ZGYpjPfjES96411YUE9EV/NBq+UVjqdK5C5w0 quPg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b2BVQNiIxf4zK6EJ/Qgk6OBXkk5862GY448IIvy5K2s=; b=Vm6k5BcT+eEVEJ46TT6Uwm34mKFOHVDGSYSsquIoVrjZ+0FFb9nGbmkKVRLBCKppf7 UDQugwUPUEDcCUedviifaxcPCYlAPStrR93JelSa4E7nPcMHB0EKINzMliw4ZgnL+oe1 zIlqIeOFp0qak2Qh8BORzv7yURrhPF0uvqVRxtGEY3tPPgdPKXQ6jWCmz+xqgayJ/ehh J8VRPZPy4LkCTEEmUu7EoOE8Wzh7DsMNaev2UH3+643CQwkgHcA2fDM8XhqjkbZ9mQ81 REn4ryiUkroQtVpfELMZDD/IySx3VryIg26aUH35fX8OzuphwMMM9WAfrMYRYiISnHKG 9nTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a53dcA0e; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w6si5739779plp.429.2019.02.09.10.56.38; Sat, 09 Feb 2019 10:56:53 -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=a53dcA0e; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728086AbfBISzh (ORCPT + 99 others); Sat, 9 Feb 2019 13:55:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:33296 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727123AbfBISsZ (ORCPT ); Sat, 9 Feb 2019 13:48:25 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0DB052192D; Sat, 9 Feb 2019 18:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549738104; bh=ZaRe8qtZ9aHUvMQzSY7TlWnOZbY3Yx9kmT3NVWM2AGU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a53dcA0eFxfIOx4fhMlbk1IICEmhPnzUoPGMeyKeBoIdMK7dXEzQXtP9yOz0m+WqN etWDe5HQcj1lzy2Jj8x8YpoGG2ACSiW+VcPLpwSk/C66c9iQWd9iQXjZqqSByn/k8J C+y3+E0mmmyiiT4Sj4GMF5XLs3fXJJEPPTp/bdfU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nicholas Mc Guire , Linus Walleij , Sasha Levin Subject: [PATCH AUTOSEL 4.20 35/42] gpio: pl061: handle failed allocations Date: Sat, 9 Feb 2019 13:47:27 -0500 Message-Id: <20190209184734.125935-35-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190209184734.125935-1-sashal@kernel.org> References: <20190209184734.125935-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nicholas Mc Guire [ Upstream commit df209c43a0e8258e096fb722dfbdae4f0dd13fde ] devm_kzalloc(), devm_kstrdup() and devm_kasprintf() all can fail internal allocation and return NULL. Using any of the assigned objects without checking is not safe. As this is early in the boot phase and these allocations really should not fail, any failure here is probably an indication of a more serious issue so it makes little sense to try and rollback the previous allocated resources or try to continue; but rather the probe function is simply exited with -ENOMEM. Signed-off-by: Nicholas Mc Guire Fixes: 684284b64aae ("ARM: integrator: add MMCI device to IM-PD1") Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- arch/arm/mach-integrator/impd1.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c index a109f6482413..0f916c245a2e 100644 --- a/arch/arm/mach-integrator/impd1.c +++ b/arch/arm/mach-integrator/impd1.c @@ -393,7 +393,11 @@ static int __ref impd1_probe(struct lm_device *dev) sizeof(*lookup) + 3 * sizeof(struct gpiod_lookup), GFP_KERNEL); chipname = devm_kstrdup(&dev->dev, devname, GFP_KERNEL); - mmciname = kasprintf(GFP_KERNEL, "lm%x:00700", dev->id); + mmciname = devm_kasprintf(&dev->dev, GFP_KERNEL, + "lm%x:00700", dev->id); + if (!lookup || !chipname || !mmciname) + return -ENOMEM; + lookup->dev_id = mmciname; /* * Offsets on GPIO block 1: -- 2.19.1