Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3701678imu; Mon, 28 Jan 2019 09:16:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN4XJRemhIldciXMyMxahPdSGX7lV5+ldAT9nZzW+Q4pgdLndUGoSsJFdM5p4sFgXHrd2UI/ X-Received: by 2002:a63:334a:: with SMTP id z71mr20747998pgz.400.1548695819108; Mon, 28 Jan 2019 09:16:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548695819; cv=none; d=google.com; s=arc-20160816; b=iCnCQxjIVMq1MG/SBI+5Y/b/LjXpHFCGfkKRz0yzfAMlWuf3ErfnthZPVH71w+ZVNP ePvZcjAIgCd7eAYNj2tQy4sKEknLhwQ+ERHCkKpO9MH4w/PXZ7I3tluqdDqOjZJyCQKp Nk7urJvQRIuZSSv0NG2k2frBGb8dZTpIubLT4qLpXU7OpwpHM4NsDpYu/6wKwzhHZf5y ZJJJeH+Vh6rHsLbeLqMXxPkVRryVw1UwwCVv6DXAJiCGEJTKcI59p20sUr2gSn4UjsbT uKVc6dKaIfH9mmjGpbc0+dAnFesm7PKap4FbCKxMT55LMoeURWhZ5bWsA47q/ingtdv4 fkFw== 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=UrTS15EftVTQjGY4am1KZfSvD+QE/lkF0CFtqAt54bo=; b=euYB0s2G/ca2Nd8s+Py4tu7E0KMe1ATzTthTuL/rPcSo2hyWVVLuUX3Jtdw+hU1r8p 091VPuSbVzKV+fLdJFbzgntcdYVIDazb0vAqw3QyxcrEG5LJKlaNyS3+zEG3Yqz+VpfV fE530X4hpShoGl3KX0c7q3I2KpX03BjMjUWZ6ZOv80QJWxEmogjcGTCCCrkMvyyrmF2+ mlOW/padxzBfeILNKiLeKBYK8nI6/3HIifDx7+ZS9IYmEHFy5kDmndfrS4rof9QcNVpd OU3COpyjiuGD/txa7aZRbulM63aJwIZxNGbXfi8s2LwqJV6TjRVCYDxKKBN3Wpot6uyU z1PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K5oWZFgO; 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 i96si33554742plb.188.2019.01.28.09.16.43; Mon, 28 Jan 2019 09:16:59 -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=K5oWZFgO; 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 S1732052AbfA1QGi (ORCPT + 99 others); Mon, 28 Jan 2019 11:06:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:55700 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727985AbfA1QGf (ORCPT ); Mon, 28 Jan 2019 11:06:35 -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 18A782171F; Mon, 28 Jan 2019 16:06:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691594; bh=Br3FdFmO5Bxhwo3/NR5Z76846Tc32IX+vUHVM7Gid7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K5oWZFgOMvm/mormBqZPlrHP2Bi7d6mpwc1lYh3tRtETQ//N8W+nS8WQwJ98LoC/f gdfcq1jwspLbAowjq3wunK4Xp2Or9v9RlOvsTa4bhS3fJKpcPKYOVXgWXchNEU5bHk 9qel0wnWXViLT9en64yAQDXgKgvOTg6TZ1kQ2plE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nicholas Mc Guire , Ulf Hansson , Sasha Levin , linux-mmc@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH AUTOSEL 4.19 153/258] mmc: meson-mx-sdio: check devm_kasprintf for failure Date: Mon, 28 Jan 2019 10:57:39 -0500 Message-Id: <20190128155924.51521-153-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 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 2cfec33178c1..9841b447ccde 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