Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2653730imj; Mon, 11 Feb 2019 06:31:33 -0800 (PST) X-Google-Smtp-Source: AHgI3IboQFC+xR0lqwn+MELTC9IvjOwweBo3e/SYaLoLWggPTS+QByNokSy478xk/cY7J2Kug4tz X-Received: by 2002:a17:902:6f09:: with SMTP id w9mr38545075plk.309.1549895492985; Mon, 11 Feb 2019 06:31:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895492; cv=none; d=google.com; s=arc-20160816; b=Tg+8lQnMBCv787bYbi6mY8riROrDCdLm6Yrd2+Wjf90l1fgkEFv//GYHCQwCrwlOGc g0KRqWSatpn8xL0qJefRTHGMxOg0ao74uMH4mY6sW4Q1kuPShGCSo+jY+2CFYs5O3xVH /qDUDwigF0Ca/IIsDARofIaVgKRStcKv2G6KaPm0WZ2KrYOb20qSvhL1EzoXCgBSnk9p LZy/7nxPbw191ltn+oYoAtozK58BnEzq7yE9eJHNQjXSe+dTA0IN0ZGowiQhfCKnHFgY oBLPJu6HXPNMvunhpiImPs5R37vbmiMtKmj8eqKBcSLHAaDOiXb3vWBfAzGIVIzuoSNQ JmGQ== 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=xFP1sVVLu1/coKgrVLwBYxAt9kqkkCiZ89DRCcX8JkU=; b=F3mMvgF7xwtWYF2N6XuNejzci6hs94W9E4zm6wIjqq0IYMtI1VCYRPM87tQPzeQF9T whgJGIw+EoliO4IvvInNK40UEyvNlo9t7MxhznHCvduVc3vO+NFXkSB9Fr/OxbcVtlQG O91zATvbRM5mn7277Aw74PR+la0NfaTbQPq4YCVkptBNLWGgMU3Po0DTK4wVkWROCsla OdMm+Q3PWwd1EbtBqmeajEbZ5UJZfJ87wxv6YL+iplNYPgcIxwPH3a3Dg8BmKJvob/GV hH4EJbw3LElFAt1vSLC5h1jYpY76N9PY90H8WiKlUZFhdgCrqToWxla2dkpmEAkPAH+I KKQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QsRYQYrv; 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 c17si7733388pgd.84.2019.02.11.06.31.16; Mon, 11 Feb 2019 06:31:32 -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=QsRYQYrv; 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 S1729653AbfBKOaJ (ORCPT + 99 others); Mon, 11 Feb 2019 09:30:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:36424 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727691AbfBKOaG (ORCPT ); Mon, 11 Feb 2019 09:30:06 -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 BDD422075C; Mon, 11 Feb 2019 14:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895406; bh=aWHigvl4q892npeZOKRLcjzUYZhu9wfb9HiXXs9K6ME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QsRYQYrvGIvoQfB2gIInBrMms38WVIjtvLAv5jQ6u/+p5EjEF4kqBo0j6TOQMIHfj WzNLA0oJOwcjwZyT6tLp7uPJIPsqtP3aJmuVWq0jPMcGMXdOS9PfeEkv27iNbfn7PM tjtapPW4976w3GAuLHhtDzAXg6O7113uiaO3EJHk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Mc Guire , Geert Uytterhoeven , Sasha Levin Subject: [PATCH 4.20 195/352] pinctrl: rza1: Handle devm_kasprintf() failure cases Date: Mon, 11 Feb 2019 15:17:02 +0100 Message-Id: <20190211141859.544769780@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@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.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit db221412cd2014506642967155698825ad80f6b6 ] devm_kasprintf() may return NULL on failure of internal allocation thus the assignments are not safe if not checked. On error rza1_pinctrl_register() respectively rza1_parse_gpiochip() return negative values so -ENOMEM in the (unlikely) failure case of devm_kasprintf() should be fine here. Signed-off-by: Nicholas Mc Guire Fixes: 5a49b644b307 ("pinctrl: Renesas RZ/A1 pin and gpio controller") Signed-off-by: Geert Uytterhoeven Signed-off-by: Sasha Levin --- drivers/pinctrl/pinctrl-rza1.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pinctrl/pinctrl-rza1.c b/drivers/pinctrl/pinctrl-rza1.c index 14eb576c04a2..9cfe9d0520ac 100644 --- a/drivers/pinctrl/pinctrl-rza1.c +++ b/drivers/pinctrl/pinctrl-rza1.c @@ -1225,6 +1225,9 @@ static int rza1_parse_gpiochip(struct rza1_pinctrl *rza1_pctl, chip->base = -1; chip->label = devm_kasprintf(rza1_pctl->dev, GFP_KERNEL, "%pOFn", np); + if (!chip->label) + return -ENOMEM; + chip->ngpio = of_args.args[2]; chip->of_node = np; chip->parent = rza1_pctl->dev; @@ -1326,6 +1329,8 @@ static int rza1_pinctrl_register(struct rza1_pinctrl *rza1_pctl) pins[i].number = i; pins[i].name = devm_kasprintf(rza1_pctl->dev, GFP_KERNEL, "P%u-%u", port, pin); + if (!pins[i].name) + return -ENOMEM; if (i % RZA1_PINS_PER_PORT == 0) { /* -- 2.19.1