Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3655410pxb; Mon, 24 Jan 2022 14:33:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJy9ZSeLo/GLRQiULaf4Gd0YLk4usWJpJISc3R7pY2UzJWG/IRpJmu/uurIelD9Sr7oQwwZH X-Received: by 2002:aa7:8105:0:b0:4be:3e95:1d1b with SMTP id b5-20020aa78105000000b004be3e951d1bmr15493707pfi.57.1643063636555; Mon, 24 Jan 2022 14:33:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643063636; cv=none; d=google.com; s=arc-20160816; b=t9/xrXnUNMXC3TGXWBs+tG4XoBJ+tU7+Kp+Ye349MWQ4gsOpo9A3SlyqWMDIcmeOa2 nwbbQaqL8bfaLQc23gjk+jx2ljDiIu7G1Q8AJeJT7gY/UpxUTaf0NTRLsIqHs09PNDxS MfsvpGWu2YkgcnjCcQX1aMEmB1/KvpT6i98rrdjzR+NiOmaP8T9zPSJpaIAsGlVPKYK0 lbZBZKwfp+EyjmtyweX95F/d61qJuAVtWuieQZVnE44ALyUdQze+nEzUB+VaLbMxMhEz mnDhIBp6gfDQUCsg947qV/+HbhOLZf7Lsq2gpaGgISjvBQOO6yCs3F3wnkWPxTAuvu0g 29Dw== 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=dZ6BwTk64WrY8msyKzWksr9vRsPCIPQT5m9Dyg1xnxD24J+GU8e3R2Wf70oycJt0BR O1opHumKhJ61WND/8NSbc5/jRmwwy5btB+1VxBQ7vg5uWetS6eJCc3rOkr2J7yiVhRYq c9gMeaZJQc25QKIGS4jWfdQ9PjCw495Yt5pCEUKpEPFKcrAovHpbDb39qncBHHkjOznh wKlPDEvmQ0Afby4ZG0jwcEk9bDmrQhe9/BzRtMIfRD/gqYeIYRBCY+MQ2BzWCWaBznJ4 4wBVB6LWhXY8ccHP60T3i5M9rvyOad7LhuM3CdgXD1KWKdaUq+Jh5MoXqH4XlgVWcV3V RD8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dsIkEDc3; 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 x185si7233717pgd.359.2022.01.24.14.33.44; Mon, 24 Jan 2022 14:33:56 -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=dsIkEDc3; 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 S1356187AbiAXWbN (ORCPT + 99 others); Mon, 24 Jan 2022 17:31:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378331AbiAXVjT (ORCPT ); Mon, 24 Jan 2022 16:39:19 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 803ACC034005; Mon, 24 Jan 2022 12:24:17 -0800 (PST) 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 0B42761491; Mon, 24 Jan 2022 20:24:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFCB8C340E7; Mon, 24 Jan 2022 20:24:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055856; bh=+mc7XH6ZHrcnhKZMatKve+G3YzRkXog/jm9bBkgtgnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dsIkEDc3qQAUOaGkvaG9vthmBZjx/RtFZEjHpt5H0SbfrWTP5dV7epL4Zb097FuG7 rPhSnWSN2cbuUvuOVUPalA0kudiH6q2LgrBacB2zG3oQTn87XizbYMeeEQCXDWvbEQ Bv99fJrIg4oktKZf7n12D1/ZSAibaOxH9tgeEUWQ= 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.15 287/846] backlight: qcom-wled: Pass number of elements to read to read_u32_array Date: Mon, 24 Jan 2022 19:36:44 +0100 Message-Id: <20220124184110.822340218@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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