From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB06BC4360F for ; Mon, 18 Feb 2019 14:45:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 813C92070B for ; Mon, 18 Feb 2019 14:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550501153; bh=h/m5t+8Fc46HVPI5CiaM0kpjEZ1ogSMyXZhQCPk19uA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=YIzlRFS0bgXBNDS6O5udkPIgD/QEDHA0WR5soCZPK54usauICsnAiGt2Stv9h4wX5 ETfzUCylPVsKb5F/OjIlYLGks86sJthTzBW66su1KtBIzZ8W8YkmnzWMRtcbmDG7N9 pQiVUfCHGj1IIqq/Wr9bU4q/PgQzKJcvYzNuUfPk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731170AbfBRNrO (ORCPT ); Mon, 18 Feb 2019 08:47:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:53828 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730938AbfBRNrN (ORCPT ); Mon, 18 Feb 2019 08:47:13 -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 4E1FA21901; Mon, 18 Feb 2019 13:47:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550497632; bh=h/m5t+8Fc46HVPI5CiaM0kpjEZ1ogSMyXZhQCPk19uA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i8OuFUe0EP5UFiUjopUpqb4ZWhnHxPW7JgNYpW6Z4InRJEoRtXHzm3+6QMAwCxcWu P+ydqS3I1UHd7kkGuM8ht+4Dq9tuJMH6qC1Xx8YfcG8QSpn/PcnwKY1k25V70lfHSf qRQbUnfhmTxpHOqzJg37OsuGn0YcLMW+38RlZt58= 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.20 38/92] gpio: pl061: handle failed allocations Date: Mon, 18 Feb 2019 14:42:41 +0100 Message-Id: <20190218133458.269383958@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133454.668268457@linuxfoundation.org> References: <20190218133454.668268457@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: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.20-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