pm: pm_domain_unregister() clears the target domain registry on a repeated unregister of the same callback

オープン 初心者向け
#22,171 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
60/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c
領域
embedded-iot

調査の方向性

drivers/power/pm/pm_unregister.c から始めてください。ここでは pm_domain_unregister() が dq_rem() を呼び出し、無条件に OK を返します。インラインの driver.c 再現コードは不具合を示しています。同じドメインで同じコールバックを二度登録解除すると、そのドメインのレジストリが空になります。削除を保護するために、キューごとのメンバーシップを判定する dq_inqueue() がある include/nuttx/queue.h を確認してください。二度目の呼び出しが -ENOENT を返し、残りのコールバックがレジストリに残れば完了です。

索引モデルが issue の本文から書いたものです。

説明

Mechanism. A second pm_domain_unregister(domain, cb) for the same callback finds flink/blink already NULL; dq_rem() sets q->head = q->tail = NULL, clearing that domain's registry and silently dropping other callbacks, yet still returns OK. By source inspection, no in-tree driver re-unregisters the same callback on a normal path; this is a missing API guard, not a driver defect.

Location. drivers/power/pm/pm_unregister.c:59-74; include/nuttx/queue.h:211-238 (dq_rem), :307-308 (dq_inqueue, a per-queue link test only). Affected NuttX 13.1.0 (commit 2b5c0de5), confirmed by source inspection; measured on a hosted harness compiling the unmodified source, not sim:nsh or a board.

Trigger. Same domain, same callback, unregistered twice; a second domain stays intact.

Expected. The second unregister returns -ENOENT and leaves the other callbacks in that domain registered.

Evidence. Measured (hosted harness): before, second call returns 0, registry count 0, devB lost; after, returns -ENOENT, devB retained.

Patch. Call dq_rem() only when dq_inqueue(&cb->entry, &pdom->registry); otherwise return -ENOENT.

主要言語
C
スター
4.1k
フォーク
1.8k
平均マージ
1日 18時間
マージ済み PR(30日)
852

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/nuttx のほかの issue

apache/nuttx の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。