Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2652082imj; Mon, 11 Feb 2019 06:30:16 -0800 (PST) X-Google-Smtp-Source: AHgI3IbBSpznHH0BfVC5f63HrJmTspWOumYSAs1NtizpFfrhh8oFTYoKYqvZgjQbWXEZteFc9NRv X-Received: by 2002:a63:d005:: with SMTP id z5mr33550858pgf.64.1549895416635; Mon, 11 Feb 2019 06:30:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895416; cv=none; d=google.com; s=arc-20160816; b=JzITMLprAhsF8LVcR6G3THW0LorrKRmwrL/1EkDYabkKbe0vcgJ5hHQ9C8OloHwawt E0ush34xTUHR6DeHAz7l5G+xxqGkKjfuymx/y9tfQUnWaWHnKKNJBxe0/56lRDTYfiHS YC9DQkFRwQMXAV3l7swBSrEKiuFH7d+cw+Mmdl2n2gr7B32eNztsU7/kyIW1P3C0cI1O +ZFZN7gqQRSItGqK6JndCQFNhkTjIoTAfrnzUQZ4n4U6TBPA49jt5ZFWf8SH1t0mLMbN WaZCq83W8gsZQ7WuP2pVdnNsQTJ0GirnMJsffQSSnACBU0nLq/PjINyb+WC6/ni3TiOu eZPg== 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=YlciugombKcWN5J63iMfjdpeaAF8I3h6jX3pJsI8NhU=; b=eb9KbnIuXG2Qym0fAX4Mi25OSPZovQ02axKBjCpXSgPt4ohtdoOq1bDbJfLsgUf1tq Aa1pbAccF0OgXCb05kmuJFOPwzEo4iBll4WzAtCNAWpsi1KHBY879e2qhjUmknRYIQw1 kyZ+QEw8wzy6O1jfbFmpuQgiuGrATaau91J1nKMu/E2gZbGQC+QpUfQVPV3a3qh/UnZZ imbb688jGMHltTgWPdEDAWKsKyre89uJlEmzMeefEIwnhv4oUUk9pDvpdYAA4TTVeuab 77mLRN4oMEgUBSWuO5OEe8MVCADhvP/E3wO0phsImyKXElr367gciSpuOo/tbBRzvpiF 9PMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QMULZZOl; 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 r7si10896953ple.281.2019.02.11.06.29.59; Mon, 11 Feb 2019 06:30:16 -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=QMULZZOl; 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 S1729956AbfBKO3M (ORCPT + 99 others); Mon, 11 Feb 2019 09:29:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:35134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729344AbfBKO3G (ORCPT ); Mon, 11 Feb 2019 09:29: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 C8A4620675; Mon, 11 Feb 2019 14:29:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895345; bh=HVpm9Lb4K5qp1tA6cHfxiOp92axP7qcC0HNtDVENUFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QMULZZOl/Phg+1fc4PvrqgOSxBZs2yNOi8v5TNHc/wVj3Om3IAlSjGps/UhQ5/AOK 5C9pFVz6ToPbzL5QNoyW/OY52m+eiB86rP3VZMdMk1tHBdxkhAsCjkzz6/5d1geqv4 asD371+3OJNnbio+FxLZxjpLEsujHXdV7yH5qIvg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Mc Guire , Martin Blumenstingl , Ulf Hansson , Sasha Levin Subject: [PATCH 4.20 173/352] mmc: meson-mx-sdio: check devm_kasprintf for failure Date: Mon, 11 Feb 2019 15:16:40 +0100 Message-Id: <20190211141858.093633165@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 b0d06f1cb0e2079a3c64fb6e27c19d9a55c723a1 ] devm_kasprintf() may return NULL on failure of internal allocation thus the assignments to init.name are not safe if not checked. On error meson_mx_mmc_register_clks() returns negative values so -ENOMEM in the (unlikely) failure case of devm_kasprintf() should be fine here. Signed-off-by: Nicholas Mc Guire Fixes: ed80a13bb4c4 ("mmc: meson-mx-sdio: Add a driver for the Amlogic Meson8 and Meson8b SoCs") Acked-by: Martin Blumenstingl Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/mmc/host/meson-mx-sdio.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/mmc/host/meson-mx-sdio.c b/drivers/mmc/host/meson-mx-sdio.c index abe253c262a2..ec980bda071c 100644 --- a/drivers/mmc/host/meson-mx-sdio.c +++ b/drivers/mmc/host/meson-mx-sdio.c @@ -596,6 +596,9 @@ static int meson_mx_mmc_register_clks(struct meson_mx_mmc_host *host) init.name = devm_kasprintf(host->controller_dev, GFP_KERNEL, "%s#fixed_factor", dev_name(host->controller_dev)); + if (!init.name) + return -ENOMEM; + init.ops = &clk_fixed_factor_ops; init.flags = 0; init.parent_names = &clk_fixed_factor_parent; @@ -612,6 +615,9 @@ static int meson_mx_mmc_register_clks(struct meson_mx_mmc_host *host) clk_div_parent = __clk_get_name(host->fixed_factor_clk); init.name = devm_kasprintf(host->controller_dev, GFP_KERNEL, "%s#div", dev_name(host->controller_dev)); + if (!init.name) + return -ENOMEM; + init.ops = &clk_divider_ops; init.flags = CLK_SET_RATE_PARENT; init.parent_names = &clk_div_parent; -- 2.19.1