Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp279212pxx; Thu, 29 Oct 2020 02:21:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzR5PdPCKsbwbRAosPu6AeCtB9O8PB0X6pafFo+wGtHYWhB0ZBrTYftq2twLDjPu594zOq X-Received: by 2002:a17:906:c43:: with SMTP id t3mr3037163ejf.219.1603963311074; Thu, 29 Oct 2020 02:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603963311; cv=none; d=google.com; s=arc-20160816; b=Iewn4eY1elaixl0+lzkaKObtFiZYbFAVqBSqK29Jx3bakMfGhe8AT9RVNDZ/wjFimz 0nma9WAvE+66vfBqQBzjLdnC0wh7mOSR0TQJ0tlSSUYBfC6kTmqy5LbEYyq92AJDHwqk G9K7m/fDOiuzdRNQVlKw6xnyOl6UkfmWeU4LseUyF75wPzkwYjfh1xBRWydXayPiZz5K 7qG6S4xP3pkOlnEi1p01hlWJWz1pqtkYgZzV5EFUPzwrkBL2k8IYZPFzuvo4z2Zlxp4L xYqb9i0JzxuxeD8/EOgtwvGiYLPg6aAVYGlUdGaCybK6FO0GSKYdCHQR+UM2aqLLj9kq xDWg== 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 :message-id:date:subject:cc:to:from; bh=vJmMVBCUTEldAS8T/QHIONQc48tzEAk5Uq8s2zj+cwM=; b=LHmuvb2Ml0F2w2lsjmzOaCjxLheFHpglgzCILIGhrfvD57USvgzAtq2EOgyD5Z61gY kY0rZWCnHDUzc3WOsMjxsn/FPcpuaxNeLoXjW9t4d6MoJUHSnuMdrnIFP0qp6OeHjG9Y kH/F6kV2SsKlJPcdAMikMnHwmO7pkt/LrER4TAiBrb9aFOonzB+ZP6IaE0vB6FaSpfDD q+XQrewdeUqLBfyWEdckZuyfD2FxgC1SM+Dslprvx46BnsVfs9bK99P3n/RGitbbgWXK QxlTTu4mlWCZSHFpJW1KHqosNYtX+uzhP7I3qkD86w7PI4PSNBu09uBu6Qn5HhF9e+aw /LvA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ay11si1507840edb.464.2020.10.29.02.21.27; Thu, 29 Oct 2020 02:21:51 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726091AbgJ2JT2 (ORCPT + 99 others); Thu, 29 Oct 2020 05:19:28 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:6925 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbgJ2JT2 (ORCPT ); Thu, 29 Oct 2020 05:19:28 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4CMKdP31qKz6yyG; Thu, 29 Oct 2020 17:19:21 +0800 (CST) Received: from huawei.com (10.175.127.227) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Thu, 29 Oct 2020 17:19:11 +0800 From: Yu Kuai To: , , , CC: , , , Subject: [PATCH] leds: various: add missing put_device() call in netxbig_leds_get_of_pdata() Date: Thu, 29 Oct 2020 17:23:05 +0800 Message-ID: <20201029092305.900767-1-yukuai3@huawei.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 e6fd47365b58..68fbf0b66fad 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.25.4