Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2474694imj; Mon, 18 Feb 2019 06:39:27 -0800 (PST) X-Google-Smtp-Source: AHgI3IZDDJiUDfHgfVG/I5TcGb/9AD2Nc6AWm0/LyWg+bY7TZCnPc1EIywuZROjBoyGOcMy43yCj X-Received: by 2002:a63:d52:: with SMTP id 18mr19462994pgn.377.1550500767764; Mon, 18 Feb 2019 06:39:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550500767; cv=none; d=google.com; s=arc-20160816; b=pjRiBB0MnW0dDpsT8xIPptv7yBXJdpVqL/rUb04YEC9UKQkhi8orswaDpyu0WP0ZmI g1aeRkcOUp2BdLYoC0qccJKiT+MX4gT2DfIkjxtglMGVPkRCNXCdis7AJQCs0CC+z49H ywsuQeB9EfKN3IVt91ANyJZ6Eh2OHq/63siLPshBCVcfkSN7rsXG5te3S3yfa1Bn80xe njl23lXPjSYvUtCV1Ii1jQPqIQlMvf9H/aPBUFUBEgoSSEWAOY3gA8DGSFAKxH8yn4md NnxtR8pIttoSNqXhhZuW2sxhbWxB9DJiMuDXPffT0I/NsdX6JvYeGc8j9M7U1RU/RjhO I+jQ== 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=4R09EJDMUzz2Fs6DsHB5z67C50/dCg1Oph1+i/zslUA=; b=iYqN/PhIwsJs9w+uIuTL/9OogJ/R+bbO2QmqO/dAPFutt8e0ChMyyrz2SIFVyYVrHS jYaza8gV44H3tNDw7Jd9RukROwxZqg8RMU5n4bDXFpmYUW7I+vQWMFekaVkzt5fOxZVT exoyqCYq55jyIJ32shosQEAmP9Hl39/B9yY56sCy0soEfzFB3izJrj9pFJZBQhYz649z lhj4jbiw4M2bHHEBtT4adiZH4lVt9omt8FkmVe0/NuirP429mFdbiwpSqY+UnXLh1p9J 2AgbE65Tlrf5vxdAA2TgwtQ8VQ+kpgtwOMza3uYrZyx85xYN773r36Yv6pQ3zQ3vxTIn YmLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P3mr0ezV; 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 y11si3378759plk.323.2019.02.18.06.39.12; Mon, 18 Feb 2019 06:39: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=P3mr0ezV; 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 S2389435AbfBROgz (ORCPT + 99 others); Mon, 18 Feb 2019 09:36:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:35736 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387564AbfBRNzj (ORCPT ); Mon, 18 Feb 2019 08:55:39 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 C5688217D9; Mon, 18 Feb 2019 13:55:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550498139; bh=+MtcUgz+2BIO3VLimAln0nx98ZluIbYy8W2RGJ3o5qc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P3mr0ezVdueix98V7X7/tYZAoFQWeHuinU5hThQqFcUqKB0BDD5eh+3JuOzhoZHPh O/UxFx4ZjwO/C8u9gUkq1PpxNpTGRBiSRXXDMMbPWYkIArC9zr/ehloFTC+jifz+/7 SY6fmhAY4vZpLfhj6bTvsiqX48hzPNYpBxazHnNM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Mc Guire , Linus Walleij , Sasha Levin Subject: [PATCH 4.14 36/62] gpio: pl061: handle failed allocations Date: Mon, 18 Feb 2019 14:43:42 +0100 Message-Id: <20190218133509.025046926@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133505.801423074@linuxfoundation.org> References: <20190218133505.801423074@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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