Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2770452imj; Mon, 11 Feb 2019 08:12:36 -0800 (PST) X-Google-Smtp-Source: AHgI3IbkvkhqhKSCo86WJd10HGXybhXrT6szXQk/OXSWRF6BZqwwMuccmZa0Gv8xe0QrN6Q46e/K X-Received: by 2002:a62:31c1:: with SMTP id x184mr38379833pfx.204.1549901556587; Mon, 11 Feb 2019 08:12:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549901556; cv=none; d=google.com; s=arc-20160816; b=0vv0icNLARlKuZ56Up9on7vb0+3xIXglygpTjcGmVUYAqbJe2Xupr+XsxK6qjFxqiI tPdQsYIub7M4yKDbFSCcWMWSW/WC+4kMSAohPHADV+WpxJBIgxuYUXPG0+tEI/i9u8uK ID42GJmi4jy0WSbHFhgZjgoLuolFS2PFrBOS7sls1bQ9Wke1wQ5asGxVYeyRBLYKbYIQ DvvEM0EvNiGf5LvgIZDmg64VgFR//HvgBlcKePLI7R+lMQ0iODODTQ/hpfLz3E1a9y6d +cxYtXOJX+cOlNXeKCrBQwf3s7/xOQo2hXX8pucGAyVri9GtqTIwXOznEEqJkBOrGOiN IjfA== 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=4xgAT+tWdC9HFe6X5FxOqMKUuJ3B0rx6rPJr/BzoOew=; b=Y4ntpcVVPSFKEGpxd/QKMt6ObpnazxcAIZpUtOuzE/azWrPwB+ZxTJyb6S6lNCIigv oFPQzc0JoG8pE4rAlOuCrUTu+rS5uy8Z0z77OtVgnyyv+AhFvEcHd+WygnCxEi12Ydea ib9UNroZUVYf011HRIuGcZEFxKgcE+WiiPUTfeA9HP2quLSWeffzKzrnZnSrogaQCl/W nfmMvoOy65ZXpT7FYi2fH0b6v/aqdH0HH3fCDBm6yXbzQMvbnaXj2BaZ222YtAGV2BQ7 DDk4f/Oa9E9p5HNudtr2C9oXkaLEIrgk+0+fdP5h2XMoSLbl5sap7sAu0pzwfl6RK1uE bEzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FZR3wJlm; 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 h16si233378pgh.283.2019.02.11.08.12.15; Mon, 11 Feb 2019 08:12:36 -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=FZR3wJlm; 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 S1728554AbfBKQLY (ORCPT + 99 others); Mon, 11 Feb 2019 11:11:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:57312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726041AbfBKOYL (ORCPT ); Mon, 11 Feb 2019 09:24:11 -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 0812120838; Mon, 11 Feb 2019 14:24:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895050; bh=iIXdjZZjXEqNj9BM29tlLoq9CPaKv62aGKzTTVnn8iY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FZR3wJlmoi3T6A0fS/QrWVNhHWyj/Q/wz1AMGr5qd61p4d/E+Bapi8Es9/jGcENcr S0zreuzt5DHlLH5E67RtmvX6g10xKxpkBKm8fuliPz23b+KYmQs5FASEUQSlzBvNhp cVrBPxLnHBmxGWsJHwkYV5nGTYGmJQXiaWRH2IxU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Mc Guire , Martin Blumenstingl , Jonathan Cameron , Sasha Levin Subject: [PATCH 4.20 073/352] iio: adc: meson-saradc: check for devm_kasprintf failure Date: Mon, 11 Feb 2019 15:15:00 +0100 Message-Id: <20190211141850.714007877@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 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 028ccd218f82..672a5dee4a9d 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