Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3630971pxb; Mon, 24 Jan 2022 13:58:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXSvQgah2RifCRPI/piPzpturszecH/v527PXQhdpz2rAsHSlBCU1+fq5LaC2a1NnVUD0D X-Received: by 2002:a17:90b:78f:: with SMTP id l15mr354815pjz.40.1643061513508; Mon, 24 Jan 2022 13:58:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643061513; cv=none; d=google.com; s=arc-20160816; b=iLZHeC4cKVXCLkhkroNZo/J4lIVZH3HZoi7nTJl/0/s/XaODul71wsZlgUGNZMk0U5 aiQDU/0XgIs1gqJeITjA5p0QlnZzeQr3ypSA//IVvYqVqFm1tEQJZhYgEESZopwJbdUi bzBhG8WKrGs7ASa+rF4lHEgtTWI0lBVnIAIPbu3jr5tYsYcRjyM8uddyXN4xHV9em2+P xnk0XXk1Ocwa12QENRfNHToqbUt4FOTFpjdhHnoK7NOiC5XcRdhjIegpmQXQTUmBWB5T 7eAWbb/WCdooMvJB6tP1B7wBpPoT67xoxH4SwRMtZNBlcKIyaEXROgMbMfjHAD8aRBFW FlCw== 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=2YJDyisgzGqsAQZAgFhsh7HWwaLJFKigpcHU6HE1QZQ=; b=ModdzELCz0Tm0DrLgvsvE/1jj76Ex08aV20cI63jd+XSh+C1EM1J7BRWw/ZVugvJLd heP1yi/PDXALFaEkKWXEQZ3lU0dgn0ox0a9BihZco9zxSZ+gxQsIzVz2tbiPnMEyHxi9 BZkxy+vdBbx5F75kUWwxaj+0KZkhBP+ITQXiOhqNqDcBL9bnYM6gk3SfSxvh3tifmz/O 2ikcQBhLmeqhYRvNbsPIjCD9V6+VdVm8SLKJgZ9ACpwb0KPKjbq2lq4SFhOiQHMYRlNW 3Dgx+QF0RLQvaADOzSPU9g3k6LIeuMTYwWQRZG0obnQv9YO0VlAgD/C5npkqG57j9nsj xmzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iuRsi1I9; 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 f13si3512446plg.303.2022.01.24.13.58.15; Mon, 24 Jan 2022 13:58:33 -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=iuRsi1I9; 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 S1573789AbiAXVpy (ORCPT + 99 others); Mon, 24 Jan 2022 16:45:54 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:60402 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1447202AbiAXVKK (ORCPT ); Mon, 24 Jan 2022 16:10:10 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9C9986146B; Mon, 24 Jan 2022 21:10:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BF2AC340E5; Mon, 24 Jan 2022 21:10:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058609; bh=+mc7XH6ZHrcnhKZMatKve+G3YzRkXog/jm9bBkgtgnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iuRsi1I9gFJPcqLIuMfe0eoFFsAFLnhaF0bqvzidUqBOZOJx5GCgFR741JtsLXL92 MLvBj6/KUgAtctvVF2Nf/lEEz4EQtpY3BeDTe7c7AM2oG3wg4Ojm0fmd3gnZrp4CDL toBhxpFK8TaEwW6wbs+mbPMhVIp4JJPhvrbnv20w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marijn Suijten , AngeloGioacchino Del Regno , Daniel Thompson , Lee Jones , Sasha Levin Subject: [PATCH 5.16 0345/1039] backlight: qcom-wled: Pass number of elements to read to read_u32_array Date: Mon, 24 Jan 2022 19:35:34 +0100 Message-Id: <20220124184136.891415467@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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: Marijn Suijten [ Upstream commit e29e24bdabfeddbf8b1a4ecac1af439a85150438 ] of_property_read_u32_array takes the number of elements to read as last argument. This does not always need to be 4 (sizeof(u32)) but should instead be the size of the array in DT as read just above with of_property_count_elems_of_size. To not make such an error go unnoticed again the driver now bails accordingly when of_property_read_u32_array returns an error. Surprisingly the indentation of newlined arguments is lining up again after prepending `rc = `. Fixes: 775d2ffb4af6 ("backlight: qcom-wled: Restructure the driver for WLED3") Signed-off-by: Marijn Suijten Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Daniel Thompson Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20211115203459.1634079-3-marijn.suijten@somainline.org Signed-off-by: Sasha Levin --- drivers/video/backlight/qcom-wled.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c index 8a42ed89c59c9..d413b913fef32 100644 --- a/drivers/video/backlight/qcom-wled.c +++ b/drivers/video/backlight/qcom-wled.c @@ -1535,10 +1535,15 @@ static int wled_configure(struct wled *wled) return -EINVAL; } - of_property_read_u32_array(dev->of_node, + rc = of_property_read_u32_array(dev->of_node, "qcom,enabled-strings", wled->cfg.enabled_strings, - sizeof(u32)); + string_len); + if (rc) { + dev_err(dev, "Failed to read %d elements from qcom,enabled-strings: %d\n", + string_len, rc); + return rc; + } for (i = 0; i < string_len; ++i) { if (wled->cfg.enabled_strings[i] >= wled->max_string_count) { -- 2.34.1