Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3705768imu; Mon, 28 Jan 2019 09:20:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN6wbA5s5g+QDCikEtLGMtvcqrPc6elo9Z0eKk4+xd77obyGogVuFibxZyGtfcGGq0SrNybc X-Received: by 2002:a17:902:7b88:: with SMTP id w8mr22453681pll.320.1548696055240; Mon, 28 Jan 2019 09:20:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548696055; cv=none; d=google.com; s=arc-20160816; b=hGe2nFTPB1tcHsa6S6S3Q6GNY2I+Csu/uPC+Z76+CYxa7Zs0D8RNdPj/KP54wf9Pi7 YB0ZGqOo0wmdM6qBCcOPOgTMB7fwsdNhHMyZIawaBErJ47NgZoVfBPx5MBDbi0gG3hKd Wc0Ut5lNkesmPibFF7Tx8BGOxoVrRYyaK+zjnCbw8gOBRFc1SfLd1DWYQNxN0PFZoMtG 5cwIhcGO90dYjYnxissofvRT1XrEIqKU7/MslMwYevkjNizr1+naKT9HZ0LzPW2aD3e9 guGdRY9NJDPQr+AhlfMjIyg01cSMlnnaan+f+J0ZzK5uU6HMKQFBzM+9W8vs68gihwEW Sf3A== 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=XoFBkzPm4RGtQSwrnkx9ak3q/5OeNQMyAUQNftGnHk4=; b=PgPDj4wOidD5/L7PGgRI3eLYeZB50XKhkOH/Ja4BHydz8PJVMEes7Be2v/ye61u03B ojcyNXfT1V28Zx4raFCxwm6Npwyju5bNSsUaTlneDNqoDKxWWURY+40eE5PsHow7Grs1 blQPMSeO0gU24LFMBbC59Z0pj/iNvuLIOLQcBPRHhuVHxn0s+7yq1X6ol8C7k/e1aubl x8c7UoBs/hvzKGmT/Zg751W5EkMmiP+rR9G2iJOEo7KhbCKKbsXgGDqwRy45Sk7AhqFr 9VdfN8jiOQ14+Mhh6u5h3NVWOBskUFqYNTdmxGOtvmJ8jR2PA84BuGAooIysrJ26xuCN 9XzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EWCdeLOk; 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 f4si476236pgg.492.2019.01.28.09.20.39; Mon, 28 Jan 2019 09:20:55 -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=EWCdeLOk; 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 S1731721AbfA1QE7 (ORCPT + 99 others); Mon, 28 Jan 2019 11:04:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:50930 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731702AbfA1QEz (ORCPT ); Mon, 28 Jan 2019 11:04:55 -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 7955620989; Mon, 28 Jan 2019 16:04:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691495; bh=f0spF4CTYM5t033TBalzw1w3xyJzYaiO5209hAX0zS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EWCdeLOkN8fEoFgzQD+3ajMUZD0dCD92URpBMVSu1RHUTRR8OD2i+tYkoW9D+LMn2 UCPJpevUWxRWOtTEeDy3XUg1dbz/pwXF8weBk9gNlrmCibcZoTMq0vGJupNyIq4kOy OGgrddiV0whwf00srZIX9sgDVoWi+JtN8d8icgvw= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nicholas Mc Guire , Linus Walleij , Sasha Levin , linux-gpio@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 115/258] gpio: mt7621: report failure of devm_kasprintf() Date: Mon, 28 Jan 2019 10:57:01 -0500 Message-Id: <20190128155924.51521-115-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-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 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