Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1145816pxv; Fri, 9 Jul 2021 19:28:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsRY6ZGh/jJ4DhVBh0yW5HflHgtfdyTGYwfaqhzC5UY7d5PWIXQ4t1ThxVJqEk9ZkAUttx X-Received: by 2002:a17:906:a897:: with SMTP id ha23mr13109786ejb.164.1625884103733; Fri, 09 Jul 2021 19:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884103; cv=none; d=google.com; s=arc-20160816; b=FtdqemVSQw3TKELo4NrM1B6TFexQkL+TtaG2qJm3um9lubLraIFGc9i8kiqlHuoN83 uFKA+De0NOer6SHpHM47pJAfB8b4Q9f3PVPWhvXhPW8jmQoAAxD6bQXctVgA63G5lTA9 OTUP8PFUK+dBXIr6bPcxpnE87XWj5OnxZxcciat8ZvY5BFoqAUbX8+nrMQ5KfO+yq7sd R2GfHXZCkw1nwCKXnGceV9jH7aFbKVxV7hmV3Lc+S30wD6rkflq6bHGEk4U1Cqr+zXm2 dbN5eOD/kkDLXX+eenC26bWvQ4wJoFQGl++C7/Wqu8X+HX9sxgbo/Qxy+2RZGN1N1zJp CskQ== 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:dkim-signature; bh=THuHWGT+GDjhQDNqHkHXPnc2QYnAH0pgXbc9AE7KAdM=; b=Uo4rwjCATVdmu6uHG9RGgNL+GoHLThgLQeMq2FWCuPCpWfjcC5NH4uPQHA9gUVFdKd d684CB+tEC8N6mk+ymYX8qGe7LIMOFXTbqzxkAXP5y5Qj5XPh7Qgi6WTY3yoqDSSbvYQ HjIPgko8Zc2MxJ5QYOdnvbqnp6oQDaDDBwwL2Qy1d/vKzT7VpoEhvv9amMEphSGV1Qpn 89g6SYkCd1G/p+PdD33zYK9kYuiTYlJc+SXsfpDtlF76V3zf8jhS6qOc17jVMS2TdtzG ln3IzBWEoq6xhSTxiWjyR61r1FMtXAX8CW5okhOjbfhmv2SH7GhVw6kEdU9fajWJoyPJ 7F5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VWQ1TDSQ; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nc38si10837432ejc.708.2021.07.09.19.28.00; Fri, 09 Jul 2021 19:28:23 -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=@kernel.org header.s=k20201202 header.b=VWQ1TDSQ; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234335AbhGJC3W (ORCPT + 99 others); Fri, 9 Jul 2021 22:29:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:42926 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233826AbhGJC13 (ORCPT ); Fri, 9 Jul 2021 22:27:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6D050613DF; Sat, 10 Jul 2021 02:24:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883870; bh=YUEniXoGWoNOiBcC3NU1p9VwfWhDIBz0E7edYEnC7PY=; h=From:To:Cc:Subject:Date:From; b=VWQ1TDSQMH5W1IMmOlftquUyXHnDcomL0MqmRgiCr6gj51lnzbLeL9ESGSVZIDukg KNcKi9umLxTFtfF5pFK/VYjCF6K9DTxF0t/vlLMbthpwiUucoIT4mH4hcVQO6UrK76 XyInQEgkom5XpKcjTS0/GulOiVTeKRWfLRVMlmNYXW/iT8vTUhy3MvVIctBbEwKuAV AyD5kjFou+JppeL5RzGjDjgfpMd6NGVe34f7jSjUEh/itsO+rFt2yVf4jm6Ye4//mA F8ywNGDlhU013Cq62NOTUqwJtFP2dHYbACmHdUkaucj0h/5yej+3MX9NEE6hwuWCEr YACWkqgA4v6kQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yang Yingliang , Hulk Robot , Pavel Machek , Sasha Levin , linux-leds@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 01/93] leds: tlc591xx: fix return value check in tlc591xx_probe() Date: Fri, 9 Jul 2021 22:22:55 -0400 Message-Id: <20210710022428.3169839-1-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yang Yingliang [ Upstream commit ee522bcf026ec82ada793979c3a906274430595a ] After device_get_match_data(), tlc591xx is not checked, add check for it and also check np after dev_of_node. Reported-by: Hulk Robot Signed-off-by: Yang Yingliang Signed-off-by: Pavel Machek Signed-off-by: Sasha Levin --- drivers/leds/leds-tlc591xx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c index 5b9dfdf743ec..cb7bd1353f9f 100644 --- a/drivers/leds/leds-tlc591xx.c +++ b/drivers/leds/leds-tlc591xx.c @@ -148,16 +148,20 @@ static int tlc591xx_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct device_node *np = dev_of_node(&client->dev), *child; + struct device_node *np, *child; struct device *dev = &client->dev; const struct tlc591xx *tlc591xx; struct tlc591xx_priv *priv; int err, count, reg; - tlc591xx = device_get_match_data(dev); + np = dev_of_node(dev); if (!np) return -ENODEV; + tlc591xx = device_get_match_data(dev); + if (!tlc591xx) + return -ENODEV; + count = of_get_available_child_count(np); if (!count || count > tlc591xx->max_leds) return -EINVAL; -- 2.30.2