Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1143578pxv; Fri, 9 Jul 2021 19:23:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYEu9ohSrgUhnqALnT+lO5jlzIQxNRPXEAbyvZy5jNuP8hCt5F2PELFnkUEEiYH6agtZ9s X-Received: by 2002:a05:6402:518d:: with SMTP id q13mr50726185edd.387.1625883793209; Fri, 09 Jul 2021 19:23:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625883793; cv=none; d=google.com; s=arc-20160816; b=k3lAIpWDVr/jtg1aNFRGHTAJnDjqCj5JhCYUddXgSfhUpbgsRll05dNXNYbSnTufvj qlp7Qqnfz7VeWWvm08DKMKhMT4TQGKAYoiSLxRzOwvioDvAk7bwNfBq+k4y70rulaqam 2DKdinTScQ+GRdQpttIqzafd0kMed9LdONFlYHMjNIAtbZpbCrbTxu3RYeR2mU+YoJju 0FRlIaGc3e31umPj/gcGnMufTTiSa0q5LJDSMpWwyCDI2t4WYymjiKElLa1AF9eyP5o1 mgz5vLRsGINc97P8GparGK0mkl0jUzM+9wte2Wqc9+Td7IWEs1j/mnNDzK/kBpy9Oway J5rw== 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=jWxhb/j3u9Aya8yg6yW+Q+0y3tPJegMZtGSjzuIGfBH/qI/UYZFLUroP0o31lG1MMF nWLWSpGTOZaprp3WAjGUxp2veT6PtAAaaWG0oERRFHiASv8kVS53m0De0zOI+cW0gB/N yFW3OHH8bjkdunH0WGYJwrENmqoes9n8nXbBUjORv5CfsRf/ZgbWxiyYLgK8a+wLJasC G6gJJ+5k5it+ZWRQfMYZuee3eajMT79wcvvhyLkwWrNXg7TjYCHE4gQ33opcWp2POHI9 crpuiDC+1ssouaQCzHbBkiJ1oJuPYlWLuAr8HCTBF9G8olFP1jaUIg+ksb1yMA9nrv0B S/NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=blsH2fzy; 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 nd1si8749599ejc.631.2021.07.09.19.22.50; Fri, 09 Jul 2021 19:23:13 -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=blsH2fzy; 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 S231205AbhGJCYn (ORCPT + 99 others); Fri, 9 Jul 2021 22:24:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:41370 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230248AbhGJCYm (ORCPT ); Fri, 9 Jul 2021 22:24:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BA93E613BE; Sat, 10 Jul 2021 02:21:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883718; bh=YUEniXoGWoNOiBcC3NU1p9VwfWhDIBz0E7edYEnC7PY=; h=From:To:Cc:Subject:Date:From; b=blsH2fzyrkOyHrDZLaadFUcWhjACb81kUPzEkD67HDfBRN+lR6zI3hMusgm1Un+ys tsfEEDkROUOYRQWzGhoUyj7KKb2Eh2Y3s8StJ50boN0Jh4fb2yHk3joXam0rDNBztZ WTluYkwJ65L6RsyJO5kwKPMnuOY7Kqosg069OeY4RT18namQVeitKUF3IVxeh+gtRm Q7ok100K5k/dJ585EWh77F8qwP7MmRVgMByrk3i50CR8BKHUa8vW+n2awtqdSytmkd PlxXH+VI1erx2dvXLp7SGLEJnPe6P75oFeajNXynLTCR66J5qQzen/jQXpRLhqO1M2 r4S6AGF6BGbDQ== 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.12 001/104] leds: tlc591xx: fix return value check in tlc591xx_probe() Date: Fri, 9 Jul 2021 22:20:13 -0400 Message-Id: <20210710022156.3168825-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