Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1143003pxv; Fri, 9 Jul 2021 19:22:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjiUsFUm+RBu+33kr6kUhMFdj9NpGgMzV5nLnsNHRHN/xaF5DXlpUzcFVcSTYVKFRry1+w X-Received: by 2002:a17:906:b0d4:: with SMTP id bk20mr39793670ejb.535.1625883624339; Fri, 09 Jul 2021 19:20:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625883624; cv=none; d=google.com; s=arc-20160816; b=dLGtZ8JjzJLi5wX889wdTbo5pxdmfzh4MUOjQHNb507AJ1UsSTiyCUON6FFSXm/Wsd vR2qIUpjlnVQ25h5qXHu2rwZPtb0qoh/ZFWWntMkRwDlRUQrourkP558LWlMq8QCHyFq fldOELKFKKMTkvNu/If1TIuApaSxgTelsld6leU1oMYB48kzKHnxbEtfYbN/I+BFVi1P b+DIsuyoAATaAwopxrpQZ4lHjL3juq515OizpH1S1i+o6M5EJ2Yd3ywRhLeFoQo0oQXj v9JqIoM/L05h5hmgr7lN/xGf22pCF2zIRmT89ubJFA3Vuq4ezpG9nHEF3T36ryX8kWyQ 7h5A== 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=Actz4+FA0B2idgUzLyvEXT9P7Ikzjjw8+igwNupUDHcwgpxhSUGgVD1Un5rq1UssvT mHGTTw5Gk03DUpR1INeHzOxABlgDAz4bLljr/HEBRqeDbK2ZLzzNv7CzP38PBWVvcmro u3uJ6XptsjRvhXQuLznrOfS3t3RYzhKvX9Glis0fi9IlfIiFeo4fg1IG7bkfPVfgOXzW guH6lJMjBQIlK2cjFOutbE47XrRngL+Gz9B4+CRooGg5hr1MubHCCIYzISkjaypWxmzd wZ2wrrKx/3UWn3HtnX06YEdpbulUnfpWWe1eHvSbs9MfN/JpaC+htS4A/S+yfvDddboN roAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oJFhjhyi; 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 c12si11000792edx.372.2021.07.09.19.19.47; Fri, 09 Jul 2021 19:20:24 -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=oJFhjhyi; 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 S231225AbhGJCUf (ORCPT + 99 others); Fri, 9 Jul 2021 22:20:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:36938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229606AbhGJCUf (ORCPT ); Fri, 9 Jul 2021 22:20:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3DCC5613B5; Sat, 10 Jul 2021 02:17:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883471; bh=YUEniXoGWoNOiBcC3NU1p9VwfWhDIBz0E7edYEnC7PY=; h=From:To:Cc:Subject:Date:From; b=oJFhjhyiDa0KFohUJM4PDOYDMlmiz/Q4uQqn6a2tfAkMpNZH/fOGHbLbt6ptu6bFp rFo0LO7lw3rn8gBwpWEgRvA8B8biGrvvOb88LdBKABpoJpdJeeLBHJWtrE0tnvCXfQ XkEdskU0ddNhM3asfwArinOyP1Ewi3ryJXYQ/xT0RaBTV63L0OE4dgR9qLfE5A5ZIA 6UECK+QLbYtDRz8Gv/EyTwM3F9gXUJS9NUUmzoCoANBb+/d5UkDqUv6qOhq0kyUmnZ Duw8h0jqs83suObO1DbAaiBhbf1y1gqV01vcLF4imnp28hOBU/e+bbJqiyvzSGO36q /enTRc5+8LAug== 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.13 001/114] leds: tlc591xx: fix return value check in tlc591xx_probe() Date: Fri, 9 Jul 2021 22:15:55 -0400 Message-Id: <20210710021748.3167666-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