From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/bridge: samsung-dsim: fix TE GPIO ownership
Date: Fri, 05 Jun 2026 06:32:40 +1000 [thread overview]
Message-ID: <review-patch1-20260604114604.1422184-1-lgs201920130244@gmail.com> (raw)
In-Reply-To: <20260604114604.1422184-1-lgs201920130244@gmail.com>
Patch Review
**The bug is real and well-described.** The original code at line 1865 used `devm_gpiod_get_optional()`, but both error and teardown paths manually call `gpiod_put()`. On device detach, devres would fire and double-free the descriptor.
**The fix is correct:**
1. **`devm_gpiod_get_optional()` → `gpiod_get_optional()`** (line 1865): This removes the devres registration, making the manual `gpiod_put()` calls the sole cleanup mechanism. Correct.
2. **`dsi->te_gpio = NULL` after `gpiod_put()` in the error path** (line 1878): Good. Without this, if `samsung_dsim_register_te_irq()` fails and the caller (or a later re-attach) checks `dsi->te_gpio`, it would see a dangling pointer. This is especially relevant since `samsung_dsim_unregister_te_irq()` is called unconditionally in `samsung_dsim_host_detach()` (line 2012) — with a stale pointer that would trigger a use-after-free.
3. **`dsi->te_gpio = NULL` after `gpiod_put()` in the unregister path** (line 1890): Good defensive practice. Protects against double-unregister if `samsung_dsim_host_detach()` were ever called twice, and makes re-attach safe.
**One minor pre-existing nit (not introduced by this patch):** In the `IS_ERR()` path (line 1868-1869), the function returns an error but leaves `dsi->te_gpio` set to an error pointer. If `samsung_dsim_enable_irq()` or `samsung_dsim_disable_irq()` were called after a failed `register_te_irq()`, the `if (dsi->te_gpio)` check at lines 1606/1612 would be true (error pointers are non-NULL), leading to `gpiod_to_irq()` on an invalid descriptor. In the current call flow this doesn't happen because `register_te_irq` failure causes `samsung_dsim_host_attach` to bail out at `err_remove_bridge` before the bridge is usable, but it's still a latent hazard. A `dsi->te_gpio = NULL` or wrapping the return in a local variable would tighten it up. But that's pre-existing and out of scope for this patch.
**Reviewed-by worthy.** The commit message is clear, the Fixes tag is appropriate, the change is minimal and correct.
---
Generated by Claude Code Patch Reviewer
prev parent reply other threads:[~2026-06-04 20:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 11:46 [PATCH] drm/bridge: samsung-dsim: fix TE GPIO ownership Guangshuo Li
2026-06-04 20:32 ` Claude review: " Claude Code Review Bot
2026-06-04 20:32 ` Claude Code Review 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=review-patch1-20260604114604.1422184-1-lgs201920130244@gmail.com \
--to=claude-review@example.com \
--cc=dri-devel-reviews@example.com \
/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