Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2679939imj; Mon, 11 Feb 2019 06:56:48 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibq89pr9p2wHhrkJacUmqCeg19GhLIntyEo6Yz95RvigoZ7H6GrI+D0+7miRjn5ZY0qtckW X-Received: by 2002:a63:1b4b:: with SMTP id b11mr18842912pgm.10.1549897008433; Mon, 11 Feb 2019 06:56:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549897008; cv=none; d=google.com; s=arc-20160816; b=QeQdtH1EBOICR1tby0sWLh3Gt7YhEEGtBQ0g9Oln0nd8wkCA3jEnb1EeleFyNGFVe3 DdnxMWEMsOZgn9y1PrGNV1GSDMKk+f91ryq0t1YuSNi+d1mw2ubGNBnDxBrMDFGoCFG3 oVMNDGpDeKK261O5+WO8HS0XzDGJn25RnJyfjzLjEhLzk7PxOp+FZUlF0FDFb5BzDmvS GMtGhqMhL9I0lPTPiskvz02aKiAURZMwWQOyMEeIKTV+a2ASsxse3LMkVNJEpfGe0JsF Z0BJulUpU3ums/OkpYkh62wrZbq7Ej4A1woPhcTv4SRLTb0G5s96KNcaF+jtNbr8bH/U aUTQ== 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=hkZwLLCDQt8zcWSlfGxhzCL7/96QOH7bxDKrcR+wVS0=; b=XgR0ul0Qb8cCH6YPaSQHiukDeTN6k7y+tQ5FTR4Vtp8GbMVpy8zZYzT4tl3JgZu0Jp UhqfxIJ2F8ryUwm4A2JLzPxsQ+8MLfPCbDTLfyxNceJ43cJQHkmKdgo5zrCB+nBQCCru /PjDd08Oja7QwxMrYsqliVfW4wpSyOe8xmfH1L//BjXhMgSx3rNBS3rhwuG+OeB4E6En LNCOFJOhdax6B3kLZXlQcdi8gTxknlCca7KniS5LEo9HDYOv462gmdp+q++BrKmV3f9p gDkjeDJVpSYejRXU9L67bub/URQnLpGh0Wr/ncO2FWqB4QnKfIdgswQY5GtgySIFpl96 gg7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=h2DqTfIW; 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 g3si9218717pgq.61.2019.02.11.06.56.32; Mon, 11 Feb 2019 06:56:48 -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=h2DqTfIW; 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 S1729741AbfBKOzg (ORCPT + 99 others); Mon, 11 Feb 2019 09:55:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:42602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388978AbfBKOzc (ORCPT ); Mon, 11 Feb 2019 09:55:32 -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 97DD720700; Mon, 11 Feb 2019 14:55:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549896932; bh=yEUxfryGy9lfpQmMwqWdnw6sdLF3NIzoNXHPlLOapA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h2DqTfIW8IGaU38uX7UvBZM2K8Tkm2bJbrVgDzG4EOM/6qwT2GZPFnhaNutYBT1zf k5ziZM84+R5eFxLw1NlOlNe2QaW2Ab8y3tYF+seTnDv4K9/pteIb171ZI66zI97eNx yK76tG4kWJYeiwKw6Xw6oFl4MEBxA4J6v2zi8NNA= 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.14 036/205] iio: adc: meson-saradc: check for devm_kasprintf failure Date: Mon, 11 Feb 2019 15:17:14 +0100 Message-Id: <20190211141830.272767751@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@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.14-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 11484cb38b84..9a52a91166d2 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -585,6 +585,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); @@ -604,6 +607,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