Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Slavin Liu <bolin.liu@seu.edu.cn>
To: sven@kernel.org, j@jannau.net, kbusch@kernel.org,
	axboe@kernel.dk, hch@lst.de, sagi@grimberg.me
Cc: neal@gompa.dev, asahi@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
	bolin.liu@seu.edu.cn
Subject: [PATCH] nvme: apple: tolerate missing power-domain arrays during cleanup
Date: Sun, 13 Sep 2026 20:51:33 +0800	[thread overview]
Message-ID: <20260913125133.109849-1-bolin.liu@seu.edu.cn> (raw)

pd_count is set before either backing array is allocated. A failed
array allocation can therefore reach cleanup with a positive count but
a NULL array. Check each array before indexing it.

Detected by static analysis and reviewed with AI-assisted source auditing.

Fixes: eefa72a15ea0 ("apple-nvme: Release power domains when probe fails")
Assisted-by: LLM
Signed-off-by: Slavin Liu <bolin.liu@seu.edu.cn>
---
 drivers/nvme/host/apple.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/apple.c b/drivers/nvme/host/apple.c
index c63e28c75766..b7835e736d82 100644
--- a/drivers/nvme/host/apple.c
+++ b/drivers/nvme/host/apple.c
@@ -1398,9 +1398,9 @@ static void apple_nvme_detach_genpd(struct apple_nvme *anv)
 		return;
 
 	for (i = anv->pd_count - 1; i >= 0; i--) {
-		if (anv->pd_link[i])
+		if (anv->pd_link && anv->pd_link[i])
 			device_link_del(anv->pd_link[i]);
-		if (!IS_ERR_OR_NULL(anv->pd_dev[i]))
+		if (anv->pd_dev && !IS_ERR_OR_NULL(anv->pd_dev[i]))
 			dev_pm_domain_detach(anv->pd_dev[i], true);
 	}
 }


                 reply	other threads:[~2026-09-13 12:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260913125133.109849-1-bolin.liu@seu.edu.cn \
    --to=bolin.liu@seu.edu.cn \
    --cc=asahi@lists.linux.dev \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=j@jannau.net \
    --cc=kbusch@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=neal@gompa.dev \
    --cc=sagi@grimberg.me \
    --cc=sven@kernel.org \
    /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