Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2650418imj; Mon, 11 Feb 2019 06:28:44 -0800 (PST) X-Google-Smtp-Source: AHgI3IbbA+039QDtyVKEPVcy6rda/kpw+hqB0GWMlgX/4/cewlwFiWQMDd2ZwRyA7VaFCWkIyjmf X-Received: by 2002:a17:902:b217:: with SMTP id t23mr4994970plr.321.1549895324392; Mon, 11 Feb 2019 06:28:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895324; cv=none; d=google.com; s=arc-20160816; b=a3L0TxTgTkIsYs9mANKNNfKg72Cr3H2jisXRf+s4/YuQ/A1txz4sA/UQytOm9LsFwX 3RmyVOHSaWHH5yEpfXcJaZjEWTnkPeFa4CoJ88SI8NMpAet5XaqUFmJz+sJqXk5/cHZk 0yikCKuf3Ln3LWWRQEGsnhiCAP2j03gdsdPRenZY6XtmKGOGNit05y5H96CuGoLs5nwE AS53iEbUwFnWgZ+F9Do9i2ekTy9kMwo+2fAuVOL8gvQNJIl77pkB6GWYDTZpvrAtODqF 208Foi+Ed1v50PnsTSjIvk1rwpKVpnNFBdgARX1Nc3IDI2abs8vRuu/ni9PXvXloEs0e N7eg== 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=ITiWBkVDlimMzFrteDWYA44slKYHttLVa/b5HmNtXWI=; b=pfXHU6uzL1Z43IecVTIfLsiljiYj8Qwi/9j9B0BjZ64DmaYEiYnzHsSs3/x1FDx8ER aP1Gl4mlejoE16r7MTziWWjwncIKW17++Pvb3yvhWA88YhJDg9iA9wlhzrkhB/Cz61jI 9OlJL0KGhO9KWP3q7WE/Cx9FYLN3omyY5t8FSwa9VT5e1vdVDod87a70chUSc3KOfNkA 9I+Uty+yxtLuEmE17fXEB4glQVDLOxy9JRzdA5CPXCjZFg3n2aa2JWBiRR/G6xtOHDiN 3oaDvybkAnv/cfwUELclf4hqKxaHivrnEowohdvcD8Kx5MckUPj7YAlgrkFMhD73SGuz u9+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uINA61Y3; 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 c6si10389431plo.270.2019.02.11.06.28.28; Mon, 11 Feb 2019 06:28:44 -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=uINA61Y3; 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 S1729595AbfBKO0n (ORCPT + 99 others); Mon, 11 Feb 2019 09:26:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:60562 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729585AbfBKO0k (ORCPT ); Mon, 11 Feb 2019 09:26:40 -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 163EE20844; Mon, 11 Feb 2019 14:26:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895199; bh=85M4vKzoAraLamzV51p2zbG1ovry0x2YidPQEyhcgRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uINA61Y3A8ZCBR0ZXGTa3OWxjWlI55QzU02vTmmBiIxslogGJzEs87mS0PSMxE+uM Yq410fGm1kRkPchAqM6wswFjy4LrBqWLAa+5NzvSANSjylMQmAmOMO3R/GRETDTd+w 7XIqA3yO32i2wZARR58ucy5vD8Cscv8fN+G87Q6c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Mc Guire , Bartosz Golaszewski , Sean Wang , Linus Walleij , Sasha Levin Subject: [PATCH 4.20 127/352] gpio: mt7621: report failure of devm_kasprintf() Date: Mon, 11 Feb 2019 15:15:54 +0100 Message-Id: <20190211141854.449631253@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 59d646c775d6ae688ee90fda9f2a4270c47b7490 ] kasprintf() may return NULL on failure of internal allocation thus the assigned label is not safe if not explicitly checked. On error mediatek_gpio_bank_probe() returns negative values so -ENOMEM in the (unlikely) failure case should be fine here. Fixes: 4ba9c3afda41 ("gpio: mt7621: Add a driver for MT7621") Signed-off-by: Nicholas Mc Guire Reviewed-by: Bartosz Golaszewski Acked-by: Sean Wang Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/gpio/gpio-mt7621.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpio/gpio-mt7621.c b/drivers/gpio/gpio-mt7621.c index d72af6f6cdbd..1ec95bc18f5b 100644 --- a/drivers/gpio/gpio-mt7621.c +++ b/drivers/gpio/gpio-mt7621.c @@ -244,6 +244,8 @@ mediatek_gpio_bank_probe(struct device *dev, rg->chip.of_xlate = mediatek_gpio_xlate; rg->chip.label = devm_kasprintf(dev, GFP_KERNEL, "%s-bank%d", dev_name(dev), bank); + if (!rg->chip.label) + return -ENOMEM; ret = devm_gpiochip_add_data(dev, &rg->chip, mtk); if (ret < 0) { -- 2.19.1