Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2726180pxj; Mon, 31 May 2021 09:11:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwk2K56uKlw3uPqSqhYz7Iw5m7Lo9XIXXRRSgMLIEnezGw5ZwMcFuEf+cQvg2LyqYm+xYNg X-Received: by 2002:a02:3505:: with SMTP id k5mr20911550jaa.123.1622477499076; Mon, 31 May 2021 09:11:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622477499; cv=none; d=google.com; s=arc-20160816; b=mWRwTTjsEdtomN4q/VGqAyGBpF2sfbPi0Uc1CLN7fJhiL0wpCZR5ZKwXqiJ1p7Rwf4 T2hwoQhzZHEVfT7t+6bSEAzHuMvnA6ALGuuR+3UAPcE26UM0A4J7spkmlkhOXwpiRffZ lKpOcKt9iO1CceJZrOobIgHYM0JLvWSV7S6resqx+TMtX0mazW/T3RNk1mkpk9S8R8Ff OsB18mPmgUoVY3IYGpBWY5/EGAr2tO19HKQoRr0UAUzTM7hlMpdbIZDGcJF8+skVEpTC eAOtIfpmSPbMJliTFId6cErFdtlfya1qQrlVyhaU9g3aqMcn6YldffZNEFlO4j7NuTd0 8VxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0gNQkuY9puC7DR6+txXFJ23M/t8BXrYeceG1R0afdHY=; b=YbMp08OzQD3Z4F/zzdDrzd3TPqqFmfLmR0D1HHJxXSp406ziCLtjd0AVRCKGs6jsW1 phPE2StUWLajzWrg+AJhLcze1vaLhrYIDryhBIhXZS0DFj14smVCzlCnCxBhGuuhqYmp Hjn3EvfMStjDXsiJlFMuh7itb45IDorRlZ3c1LKKpryEMuAKYtUrqayT+NTl25nquhxr FvXjMiTRjUWPFc86fm/eThjz+wRuuHPYSvps8O2NNjCheR2Lb20G2YcMklsYB6hW1qaK 1JiBqAj/+q49ny3NkSVK8Nl2SSRJgaI51OMiURcopiJ3d9d73f25i7mRYbygp+ZJZllE yU5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uT3gajvO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j5si13400947ilr.135.2021.05.31.09.11.25; Mon, 31 May 2021 09:11:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uT3gajvO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230178AbhEaQM0 (ORCPT + 99 others); Mon, 31 May 2021 12:12:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:33264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233980AbhEaOhi (ORCPT ); Mon, 31 May 2021 10:37:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A16A161C55; Mon, 31 May 2021 13:52:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469121; bh=CnVjX5vT2irg3av9FDImDH3Pys1rwVPHHG4quadwNt8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uT3gajvOXLGuXmYwPowBMz6fwU+xPozLUT1kmUY1QkPSayg9kpn5Gutx9FFX8z5QT pmx0RK1rnbM5585fHLTxzXrM+OSU+uwGTskpKaxh5+Q5dvWXDt8eS5afMk+PhuJ9j1 QNRfNRp3e3c2qBzLcM7GAEQjDGRdmy0NWn+NFyeg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexandru Tachici , Andy Shevchenko , Alexandru Ardelean , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.12 077/296] iio: dac: ad5770r: Put fwnode in error case during ->probe() Date: Mon, 31 May 2021 15:12:12 +0200 Message-Id: <20210531130706.440210824@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Shevchenko commit 98b7b0ca0828907dbb706387c11356a45463e2ea upstream. device_for_each_child_node() bumps a reference counting of a returned variable. We have to balance it whenever we return to the caller. Fixes: cbbb819837f6 ("iio: dac: ad5770r: Add AD5770R support") Cc: Alexandru Tachici Signed-off-by: Andy Shevchenko Reviewed-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20210510095649.3302835-1-andy.shevchenko@gmail.com Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/dac/ad5770r.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) --- a/drivers/iio/dac/ad5770r.c +++ b/drivers/iio/dac/ad5770r.c @@ -524,23 +524,29 @@ static int ad5770r_channel_config(struct device_for_each_child_node(&st->spi->dev, child) { ret = fwnode_property_read_u32(child, "num", &num); if (ret) - return ret; - if (num >= AD5770R_MAX_CHANNELS) - return -EINVAL; + goto err_child_out; + if (num >= AD5770R_MAX_CHANNELS) { + ret = -EINVAL; + goto err_child_out; + } ret = fwnode_property_read_u32_array(child, "adi,range-microamp", tmp, 2); if (ret) - return ret; + goto err_child_out; min = tmp[0] / 1000; max = tmp[1] / 1000; ret = ad5770r_store_output_range(st, min, max, num); if (ret) - return ret; + goto err_child_out; } + return 0; + +err_child_out: + fwnode_handle_put(child); return ret; }