Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3708491imu; Mon, 28 Jan 2019 09:23:51 -0800 (PST) X-Google-Smtp-Source: ALg8bN5681VKoK4XfSa9d19YEd+/TtJFtuK8kwYAEqiwgBmqr2Zt7Nyc6ECj2pIWdBRWYR62JU9a X-Received: by 2002:a63:d70e:: with SMTP id d14mr20701731pgg.159.1548696231073; Mon, 28 Jan 2019 09:23:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548696231; cv=none; d=google.com; s=arc-20160816; b=lA3qq84WV5zNt8s5tYNbIXYoslDvY+FiWooZe386XTrXzIsl6Ypra8ugrp+SA2AoIA UMyK+uD8O3SwuhiPokETSy/XD44d9RdWWjcFTEHj4Vy3GMmsTzk1sVUrQ0vKX40eplVp /sZ2Em1FMOitdPMNrTynJ6ft/TlXLZyU+HrO/W7lhqgfl4V2gZSdH7FlXuwDyGZycEB/ RTXf5wvSMNtrMt93XF3AFgaHaZm1pNqxzRgxZHX9HMXlrkoe0MNfT5h8Txk8hYWVt6ZR 3U8YBBXtjiNCNXwxWoaJko2BNjcHXb8LmsjlglT4uP1JqdXCSOguJJ5lD/pgwvt32yOV xOSQ== 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=zvPWkgjkwjeR3Qq7QpkXbQKF6E1W0w6ruiYNQDFoBtQ=; b=JPWpbsok+kMPZXM23zkG6ZZJS/yT4PUeYl5GArlpkmvfuvqQx6w/Q+63KzyNz8zeWh H0yV2xHVfa+T2Q6GN860GrcPsj1uZODEu1mshzoM6Kzc8x+6D4piFWQsxEok5voTEQ/x TfGwgW34g0uYhh75be21+Jdmx4543F76s8gSHoUPYkbje1TCTyyXU/1TIpo4SJcboUNA cmwdXP2qMo5128Ryh63Omu3cXddBdDtlUvytQ8NNWhyshunzZC0+j1hQhYJ0izXcrn6m 3OdnAYBfn07+o2ASOy5T2BNvSj88/T0hu8cFFvmkjhlwsM74jmPYOf9Ydmow2JlUhW1r 34mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GdgDTy+j; 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 e6si1445067pgl.471.2019.01.28.09.23.35; Mon, 28 Jan 2019 09:23:51 -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=GdgDTy+j; 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 S1731261AbfA1QCk (ORCPT + 99 others); Mon, 28 Jan 2019 11:02:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:47936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731254AbfA1QCg (ORCPT ); Mon, 28 Jan 2019 11:02:36 -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 C1AC721848; Mon, 28 Jan 2019 16:02:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691356; bh=ksyqAxsdi17NA/ckmWFnZP/js1AKsQqIMJxepDtbAW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GdgDTy+jIvL7zpkiWdr7jHFwNUVteNskTZw0EwcYiffD7N1e3RlVVcrmPQK+97Vwb FwEVY0q6rdzc0HgYCbUpZaWIMn+BHB5I6KqnFi6GgGt586ohV4i94JwmJEdouGiahj KNeTelOFb2+XwLoGtcxsElv5pF21+jaHsqfODjxU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nicholas Mc Guire , Jonathan Cameron , Sasha Levin , linux-iio@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH AUTOSEL 4.19 066/258] iio: adc: meson-saradc: check for devm_kasprintf failure Date: Mon, 28 Jan 2019 10:56:12 -0500 Message-Id: <20190128155924.51521-66-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 aad172b017617994343e36d8659c69e14cd694fd ] 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_sar_adc_clk_init() returns negative values so -ENOMEM in the (unlikely) failure case of devm_kasprintf() should be fine here. Signed-off-by: Nicholas Mc Guire Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs") Acked-by: Martin Blumenstingl Tested-by: Martin Blumenstingl Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/adc/meson_saradc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index da2d16dfa63e..da4c391b8977 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -589,6 +589,9 @@ static int meson_sar_adc_clk_init(struct iio_dev *indio_dev, init.name = devm_kasprintf(&indio_dev->dev, GFP_KERNEL, "%pOF#adc_div", indio_dev->dev.of_node); + if (!init.name) + return -ENOMEM; + init.flags = 0; init.ops = &clk_divider_ops; clk_parents[0] = __clk_get_name(priv->clkin); @@ -608,6 +611,9 @@ static int meson_sar_adc_clk_init(struct iio_dev *indio_dev, init.name = devm_kasprintf(&indio_dev->dev, GFP_KERNEL, "%pOF#adc_en", indio_dev->dev.of_node); + if (!init.name) + return -ENOMEM; + init.flags = CLK_SET_RATE_PARENT; init.ops = &clk_gate_ops; clk_parents[0] = __clk_get_name(priv->adc_div_clk); -- 2.19.1