Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4065583pxb; Mon, 4 Oct 2021 16:36:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3U4Pam4o9m68WNvOT3cOnnHvNkmi4RoLJplwBcDUVIK/TMc3h72cRzppqsicWkyaS8kn4 X-Received: by 2002:a17:906:6844:: with SMTP id a4mr9811678ejs.65.1633390618936; Mon, 04 Oct 2021 16:36:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633390618; cv=none; d=google.com; s=arc-20160816; b=q/ASNl4/3KXe764GpSVABovwBTa60vIymoTq1C6XNggjVor/5irgY7SiZnyrgSjjbS H/U6kY58KHtv9j2yOa0W1uEqBH7bKeCPs5+lhqeRhPz8z9bMlpHP8lwJAUtX4njBb73o VU0izngm+k0o3rwm5E7UbllyaYp52I8oN9lfoFxKBXpuNNN6IDC4dehfh23x9JXOdHwz RW36cM0XJeGwejhLMRLXdssHtEvV0tF3f9SKDXyZuOpCCNFuA+3PD/HsQcXGoTTfYxKU B6ES9UWjuVJwbCvN0sVIuET0Fb+sl61VoMW3mWO7HacWc8Sq1rg9g/ClSnjgQtNkDBLQ IsKA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=DFPsyQWykMz256Dv4KzTjmKWp6CA48ws/2Z7gatfEnU=; b=yGYOc/y15jCZ2ZExkAH2yc2/wk8cojJKLQ0moPrgiabrliv5By1UqxyjMAwTcJUcS1 DID2H+zlGZFKTlDA0cs2WDxkCdcsn2OwOomls4d5UBiIw2+13BLNUGwc1kBKxDv6bIPm SEp5rtlfBCL1Ze9zY8fioF5MBLD4zkW3ejz2JB9Mw0eM5kDqrwm2F3s6ZOYR6BFkxfm1 AO/ayVa+6xdq+WsZQDcx16UKmmv3u4b8xYZjj7IvhbrPFKFqxAL4XKiwvp0Nl9RVG4/q lKC2N3JS7D37A1tsXYLE41M/yKsOTDmZVvzBqOO55e9xI557u4DMCWl3vV/mq3SjPWiw G7dg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m16si2543385edv.312.2021.10.04.16.36.35; Mon, 04 Oct 2021 16:36:58 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238905AbhJDT3g (ORCPT + 99 others); Mon, 4 Oct 2021 15:29:36 -0400 Received: from relay01.th.seeweb.it ([5.144.164.162]:48671 "EHLO relay01.th.seeweb.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236024AbhJDT3f (ORCPT ); Mon, 4 Oct 2021 15:29:35 -0400 Received: from Marijn-Arch-PC.localdomain (94-209-165-62.cable.dynamic.v4.ziggo.nl [94.209.165.62]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by m-r1.th.seeweb.it (Postfix) with ESMTPSA id EEBAF1F67F; Mon, 4 Oct 2021 21:27:43 +0200 (CEST) From: Marijn Suijten To: phone-devel@vger.kernel.org, Andy Gross , Bjorn Andersson , Lee Jones , Daniel Thompson , Jingoo Han Cc: ~postmarketos/upstreaming@lists.sr.ht, AngeloGioacchino Del Regno , Konrad Dybcio , Martin Botka , Jami Kettunen , Pavel Dubrova , Marijn Suijten , Kiran Gunda , Courtney Cavin , Bryan Wu , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/10] backlight: qcom-wled: Pass number of elements to read to read_u32_array Date: Mon, 4 Oct 2021 21:27:32 +0200 Message-Id: <20211004192741.621870-2-marijn.suijten@somainline.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004192741.621870-1-marijn.suijten@somainline.org> References: <20211004192741.621870-1-marijn.suijten@somainline.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Fixes: 775d2ffb4af6 ("backlight: qcom-wled: Restructure the driver for WLED3") Signed-off-by: Marijn Suijten Reviewed-by: AngeloGioacchino Del Regno --- drivers/video/backlight/qcom-wled.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c index d094299c2a48..6af808af2328 100644 --- a/drivers/video/backlight/qcom-wled.c +++ b/drivers/video/backlight/qcom-wled.c @@ -1528,11 +1528,18 @@ static int wled_configure(struct wled *wled) string_len = of_property_count_elems_of_size(dev->of_node, "qcom,enabled-strings", sizeof(u32)); - if (string_len > 0) - of_property_read_u32_array(dev->of_node, + if (string_len > 0) { + 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 -EINVAL; + } + } return 0; } -- 2.33.0