Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9101972pxu; Mon, 28 Dec 2020 06:41:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvuUU3dSN+jheacVXVX7qfHlEl7FZxz2ZVBdyiESK1gKfn+a8sbswHoAau1GccPWYOF/hf X-Received: by 2002:a17:906:5293:: with SMTP id c19mr42506819ejm.72.1609166474952; Mon, 28 Dec 2020 06:41:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166474; cv=none; d=google.com; s=arc-20160816; b=bVYRJJFYwdj0c8vRN3bXxzMKvsfGY5jQmwYmVouRufLT2lE/N628Gx3rkfRoERuMPQ 2ImwaJtxAKPPsCzlH3YwMpaolVAlS9je+7shUm1T/n1KTC6q4w1Ia12KDVwiw3R9JMpy eeT5ZtUUvCzeM15UsBWo4BVBRFYuHJTwH+eFhROaSI549SiOh9QfTsNWP342Wq4WEFaH pwTCEOrX1edZFEbeAiskREge2fsYPQDQ4x5RbBbFR3fX+QcoDuie39MGuOWgtwy577yG QNyoSnuWBnWEF/ZOZe7CvzYttN7H9djKlPHL3bH+eb8exFeXbCJiXv/Z+Baf8B0KPajy cXbw== 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=t1JsRjcm0AOcymqTU/z0CK/xkOLKcQUNSr/1h2gCjFw=; b=oKOOwrOMqeFupG+nMgn+gGf1xXB4W4XNzV5k2PCNfkNkeQYJL2c07SaK6qFgnkRFnr 6e4V64vwu7RWG8cYf3ckOkFElQkpN5PunSfaFwTqx4Nn+1Abpfbm/jzCY9j3dJui/rMz J3mL0JYa2PBnwxMytg7IgsbhECSuYfzizeA3dyxiX9WWdB1HQ+G77OvzMclT9uAfJXVU qAHcrRGY7T7uzhPbFh7rBQGbgppua4xbG/2681vZO5n12UQxizce5xg9n/cptwSSWdG6 4d1cT9K1WLehWEbt0vPMDM1e28+14wNvqW9lB3F00neUGPYiccRgV5wMV/6adVs8opjX CNug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="XgDNz5/h"; 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 dn14si16879781ejc.555.2020.12.28.06.40.51; Mon, 28 Dec 2020 06:41:14 -0800 (PST) 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="XgDNz5/h"; 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 S2505276AbgL1OfZ (ORCPT + 99 others); Mon, 28 Dec 2020 09:35:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:40610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2505022AbgL1Od1 (ORCPT ); Mon, 28 Dec 2020 09:33:27 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id ACB4D20715; Mon, 28 Dec 2020 14:33:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165992; bh=IxFc7aTdCQTIMkYAxsagQUyI2b3lyctfvlzezdqIlAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XgDNz5/hU2tznEgxnxfNH+k3IoaLUJ0guIK4YeIjZXOTc0Q/jBZ81JdKkf/bbVuRS 6NQ+sXd7Ro9VoK4JoyD1UA+0ajeo6nqQzLcNOkuz6Qh113NpTrkZqsF6zXyxswAYgP q12rbqZIj7EMn+mfstgDChRz0hdzbwuxLKxneXAc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yu Kuai , Pavel Machek , Sasha Levin Subject: [PATCH 5.10 203/717] leds: netxbig: add missing put_device() call in netxbig_leds_get_of_pdata() Date: Mon, 28 Dec 2020 13:43:21 +0100 Message-Id: <20201228125030.706869763@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Yu Kuai [ Upstream commit 311066aa9ebcd6f1789c829da5039ca02f2dfe46 ] if of_find_device_by_node() succeed, netxbig_leds_get_of_pdata() doesn't have a corresponding put_device(). Thus add jump target to fix the exception handling for this function implementation. Fixes: 2976b1798909 ("leds: netxbig: add device tree binding") Signed-off-by: Yu Kuai Signed-off-by: Pavel Machek Signed-off-by: Sasha Levin --- drivers/leds/leds-netxbig.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/leds/leds-netxbig.c b/drivers/leds/leds-netxbig.c index e6fd47365b588..68fbf0b66fadd 100644 --- a/drivers/leds/leds-netxbig.c +++ b/drivers/leds/leds-netxbig.c @@ -448,31 +448,39 @@ static int netxbig_leds_get_of_pdata(struct device *dev, gpio_ext = devm_kzalloc(dev, sizeof(*gpio_ext), GFP_KERNEL); if (!gpio_ext) { of_node_put(gpio_ext_np); - return -ENOMEM; + ret = -ENOMEM; + goto put_device; } ret = netxbig_gpio_ext_get(dev, gpio_ext_dev, gpio_ext); of_node_put(gpio_ext_np); if (ret) - return ret; + goto put_device; pdata->gpio_ext = gpio_ext; /* Timers (optional) */ ret = of_property_count_u32_elems(np, "timers"); if (ret > 0) { - if (ret % 3) - return -EINVAL; + if (ret % 3) { + ret = -EINVAL; + goto put_device; + } + num_timers = ret / 3; timers = devm_kcalloc(dev, num_timers, sizeof(*timers), GFP_KERNEL); - if (!timers) - return -ENOMEM; + if (!timers) { + ret = -ENOMEM; + goto put_device; + } for (i = 0; i < num_timers; i++) { u32 tmp; of_property_read_u32_index(np, "timers", 3 * i, &timers[i].mode); - if (timers[i].mode >= NETXBIG_LED_MODE_NUM) - return -EINVAL; + if (timers[i].mode >= NETXBIG_LED_MODE_NUM) { + ret = -EINVAL; + goto put_device; + } of_property_read_u32_index(np, "timers", 3 * i + 1, &tmp); timers[i].delay_on = tmp; @@ -488,12 +496,15 @@ static int netxbig_leds_get_of_pdata(struct device *dev, num_leds = of_get_available_child_count(np); if (!num_leds) { dev_err(dev, "No LED subnodes found in DT\n"); - return -ENODEV; + ret = -ENODEV; + goto put_device; } leds = devm_kcalloc(dev, num_leds, sizeof(*leds), GFP_KERNEL); - if (!leds) - return -ENOMEM; + if (!leds) { + ret = -ENOMEM; + goto put_device; + } led = leds; for_each_available_child_of_node(np, child) { @@ -574,6 +585,8 @@ static int netxbig_leds_get_of_pdata(struct device *dev, err_node_put: of_node_put(child); +put_device: + put_device(gpio_ext_dev); return ret; } -- 2.27.0