Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Svyatoslav Ryhel" <clamor95@gmail.com>
Cc: conor+dt@kernel.org, robh@kernel.org,
	dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v4 13/14] video: backlight: lm3533_bl: Implement backlight_scale property
Date: Sat, 06 Jun 2026 05:17:00 +0000	[thread overview]
Message-ID: <20260606051701.51F021F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260606045738.21050-14-clamor95@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Sysfs show functions `show_linear` and `show_als_en` incorrectly treat a set hardware bit as an error, leaking uninitialized kernel memory to userspace.
--

commit 5b473ee9a07b0b9fd223194515f44e1ffe1b934d
Author: Svyatoslav Ryhel <clamor95@gmail.com>

video: backlight: lm3533_bl: Implement backlight_scale property

Since the device supports linear and non-linear modes, implement the
backlight_scale property to describe this state.

> diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c
> index 4f8cde9f290d0..2aa4b86042ff2 100644
> --- a/drivers/video/backlight/lm3533_bl.c
> +++ b/drivers/video/backlight/lm3533_bl.c
> @@ -142,6 +142,7 @@ static ssize_t store_linear(struct device *dev, struct device_attribute *attr,
>  {
>  	struct lm3533_bl *bl = dev_get_drvdata(dev);
>  	int ctrlbank = lm3533_bl_get_ctrlbank_id(bl);
> +	struct backlight_device *bd = bl->bd;
>  	unsigned long linear;
>  	int ret;
>  
> @@ -153,6 +154,9 @@ static ssize_t store_linear(struct device *dev, struct device_attribute *attr,
>  	if (ret)
>  		return ret;
>  
> +	bd->props.scale = linear ? BACKLIGHT_SCALE_LINEAR :
> +				   BACKLIGHT_SCALE_NON_LINEAR;
> +
>  	return len;
>  }

[Severity: High]
This isn't a bug introduced by this patch, but looking at the adjacent
show_linear() and show_als_en() functions:

drivers/video/backlight/lm3533_bl.c:show_linear() {
    ...
	ret = regmap_test_bits(bl->regmap, LM3533_REG_CTRLBANK_AB_BCONF,
			       CTRLBANK_AB_BCONF_MODE(ctrlbank));
	if (ret)
		return ret;
    ...
}

If the hardware bit is set, regmap_test_bits() returns 1. Since the check is
if (ret), it immediately returns 1 to the sysfs core without calling
scnprintf() to populate the buffer.

Does this cause the sysfs core to interpret this as one byte successfully
written and copy the first byte of the unwritten buffer to userspace, leaking
potentially uninitialized kernel memory?

Should the check instead be `if (ret < 0)`?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260606045738.21050-1-clamor95@gmail.com?part=13

  reply	other threads:[~2026-06-06  5:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-06  4:57 [PATCH v4 00/14] mfd: lm3533: convert to OF bindings, improve support Svyatoslav Ryhel
2026-06-06  4:57 ` [PATCH v4 01/14] dt-bindings: leds: Document TI LM3533 LED controller Svyatoslav Ryhel
2026-06-06  4:57 ` [PATCH v4 02/14] mfd: lm3533: Remove driver specific regmap wrappers Svyatoslav Ryhel
2026-06-06  6:53   ` Andy Shevchenko
2026-06-06  7:22     ` Svyatoslav Ryhel
2026-06-06  4:57 ` [PATCH v4 03/14] mfd: lm3533: Remove extern from shared functions in the header Svyatoslav Ryhel
2026-06-06  6:46   ` Andy Shevchenko
2026-06-06  4:57 ` [PATCH v4 04/14] mfd: lm3533: Pass only regmap and light sensor presence to child devices Svyatoslav Ryhel
2026-06-06  4:57 ` [PATCH v4 05/14] iio: light: lm3533-als: Remove redundant pdata helpers Svyatoslav Ryhel
2026-06-06  4:57 ` [PATCH v4 06/14] mfd: lm3533-core: " Svyatoslav Ryhel
2026-06-06  4:57 ` [PATCH v4 07/14] mfd: lm3533: Switch sysfs_create_group() to device_add_group() Svyatoslav Ryhel
2026-06-06  4:57 ` [PATCH v4 08/14] mfd: lm3533: Convert to use OF bindings Svyatoslav Ryhel
2026-06-06  5:14   ` sashiko-bot
2026-06-06  4:57 ` [PATCH v4 09/14] mfd: lm3533: Add support for VIN power supply Svyatoslav Ryhel
2026-06-06  4:57 ` [PATCH v4 10/14] mfd: lm3533: Set DMA mask Svyatoslav Ryhel
2026-06-06  5:08   ` sashiko-bot
2026-06-06  4:57 ` [PATCH v4 11/14] video: backlight: lm3533_bl: Improve logic of sysfs functions Svyatoslav Ryhel
2026-06-06  5:12   ` sashiko-bot
2026-06-06  4:57 ` [PATCH v4 12/14] video: backlight: lm3533_bl: Set initial mapping mode from DT Svyatoslav Ryhel
2026-06-06  5:16   ` sashiko-bot
2026-06-06  4:57 ` [PATCH v4 13/14] video: backlight: lm3533_bl: Implement backlight_scale property Svyatoslav Ryhel
2026-06-06  5:17   ` sashiko-bot [this message]
2026-06-06  4:57 ` [PATCH v4 14/14] video: leds: backlight: lm3533: Support getting LED sources from DT Svyatoslav Ryhel
2026-06-06  5:21   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260606051701.51F021F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=clamor95@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox