Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Markus Probst via B4 Relay"
	<devnull+markus.probst.posteo.de@kernel.org>
Cc: ojeda@kernel.org, robh@kernel.org, devicetree@vger.kernel.org,
	conor+dt@kernel.org
Subject: Re: [PATCH v13 2/2] platform: Add initial synology microp driver
Date: Sat, 30 May 2026 03:09:58 +0000	[thread overview]
Message-ID: <20260530030959.42D071F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260530-synology_microp_initial-v13-2-aa2bb9c56efc@posteo.de>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Critical] The dynamically allocated name for the conditionally registered alert LED is dropped prematurely, leaving a dangling pointer in the LED subsystem.
- [Medium] Concurrent LED operations can interleave serial commands, corrupting the communication protocol with the microcontroller.
- [Medium] Setting an LED's brightness to a non-zero value fails to override and disable hardware blinking.
- [Low] The config SYNOLOGY_MICROP depends on a non-existent symbol RUST_SERIAL_DEV_BUS_ABSTRACTIONS.
--

commit 1779a8eccc4d1fbf66dab42036dc8b8505625855
Author: Markus Probst <markus.probst@posteo.de>

platform: Add initial synology microp driver

Add an initial synology microp driver, written in Rust. The driver targets a
microcontroller found in Synology NAS devices to support controlling of the
power led, status led, alert led and usb led.

> diff --git a/drivers/platform/synology_microp/Kconfig b/drivers/platform/synology_microp/Kconfig
> new file mode 100644
> --- /dev/null
> +++ b/drivers/platform/synology_microp/Kconfig
> @@ -0,0 +1,13 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +config SYNOLOGY_MICROP
> +	tristate "Synology Microp driver"
> +	depends on LEDS_CLASS && LEDS_CLASS_MULTICOLOR
> +	depends on RUST_SERIAL_DEV_BUS_ABSTRACTIONS

[Severity: Low]
Does RUST_SERIAL_DEV_BUS_ABSTRACTIONS exist in the kernel tree?

Kconfig guidelines state that all dependencies must correspond to a valid
config definition.

Could this missing symbol cause silent build failures by preventing the
driver from ever being enabled?

[ ... ]
> diff --git a/drivers/platform/synology_microp/command.rs b/drivers/platform/synology_microp/command.rs
> new file mode 100644
> --- /dev/null
> +++ b/drivers/platform/synology_microp/command.rs
[ ... ]
> +impl Command {
> +    pub(crate) fn write(self, dev: &serdev::Device<Bound>) -> Result {
> +        dev.write_all(
> +            match self {
[ ... ]
> +                Self::EsataLed(led::State::Off) => &[0x4C, 0x45, 0x33],
> +            },
> +            serdev::Timeout::Max,
> +        )?;
> +        dev.wait_until_sent(serdev::Timeout::Max);
> +        Ok(())
> +    }
> +}

[Severity: Medium]
Since multiple LEDs share the same serdev bus, can their operations (like
brightness_set and blink_set) be called concurrently from different sysfs
contexts?

Without a driver-wide lock protecting the dev.write_all() and
dev.wait_until_sent() sequence here, could concurrent calls interleave
bytes in the UART transmit buffer and corrupt the communication protocol
with the microcontroller?

[ ... ]
> diff --git a/drivers/platform/synology_microp/led.rs b/drivers/platform/synology_microp/led.rs
> new file mode 100644
> --- /dev/null
> +++ b/drivers/platform/synology_microp/led.rs
[ ... ]
> +impl Data {
> +    pub(super) fn register<'a>(
> +        dev: &'a serdev::Device<Bound>,
> +        model: &'a Model,
> +    ) -> impl PinInit<Self, Error> + 'a {
> +        pin_init_scope(move || {
> +            if let Some(color) = model.led_alert {
> +                let name =
> +                    CString::try_from_fmt(fmt!("synology:{}:alarm", color.as_c_str().to_str()?))?;
> +                devres::register(
> +                    dev.as_ref(),
> +                    led::DeviceBuilder::new().color(color).name(&name).build(

[Severity: Critical]
Since the name variable is a local CString scoped to the if let block, won't
it be dropped at the end of the block?

The LED core doesn't copy the string, so could passing the reference &name
leave a dangling pointer that triggers a use-after-free when sysfs,
tracepoints, or triggers access it later?

> +                        dev,
> +                        try_pin_init!(LedHandler {
> +                            blink <- new_mutex!(false),
> +                            command: Command::AlertLed,
> +                        }),
> +                    ),
> +                    GFP_KERNEL,
> +                )?;
> +            }
[ ... ]
> +    fn brightness_set(
> +        &self,
> +        dev: &Self::Bus,
> +        _classdev: &led::Device<Self>,
> +        brightness: u32,
> +    ) -> Result<()> {
> +        let mut blink = self.blink.lock();
> +        (self.command)(if brightness == 0 {
> +            *blink = false;
> +            State::Off
> +        } else if *blink {
> +            State::Blink
> +        } else {
> +            State::On
> +        })

[Severity: Medium]
The LED subsystem API semantics normally dictate that writing a non-zero
value to the brightness sysfs file must stop any active hardware blinking
and turn the LED solid on.

By preserving State::Blink here when brightness is greater than 0, does this
force users to explicitly write 0 to brightness to stop the blinking before
they can turn it solid on?

> +        .write(dev)?;
> +
> +        Ok(())
> +    }
[ ... ]
> +    fn brightness_set(
> +        &self,
> +        dev: &Self::Bus,
> +        classdev: &led::MultiColorDevice<Self>,
> +        brightness: u32,
> +    ) -> Result<()> {
[ ... ]
> +        Command::StatusLed(
> +            color,
> +            if subled_brightness == 0 {
> +                State::Off
> +            } else if *blink {
> +                State::Blink
> +            } else {
> +                State::On
> +            },
> +        )

[Severity: Medium]
Similarly to the standard LedHandler, does preserving State::Blink here
when setting a non-zero brightness break the LED subsystem expectation
that brightness > 0 overrides and stops blinking?

> +        .write(dev)
> +    }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260530-synology_microp_initial-v13-0-aa2bb9c56efc@posteo.de?part=2

      reply	other threads:[~2026-05-30  3:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-30  1:17 [PATCH v13 0/2] Introduce Synology Microp driver Markus Probst via B4 Relay
2026-05-30  1:17 ` [PATCH v13 1/2] dt-bindings: embedded-controller: Add synology microp devices Markus Probst via B4 Relay
2026-05-30  2:14   ` sashiko-bot
2026-05-30  1:17 ` [PATCH v13 2/2] platform: Add initial synology microp driver Markus Probst via B4 Relay
2026-05-30  3:09   ` sashiko-bot [this message]

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=20260530030959.42D071F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=devnull+markus.probst.posteo.de@kernel.org \
    --cc=ojeda@kernel.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