Skip to content

Commit d525ecf

Browse files
pchelkin91gregkh
authored andcommitted
nvme-apple: drop invalid put of admin queue reference count
commit ba9d308 upstream. Commit 03b3bcd ("nvme: fix admin request_queue lifetime") moved the admin queue reference ->put call into nvme_free_ctrl() - a controller device release callback performed for every nvme driver doing nvme_init_ctrl(). nvme-apple sets refcount of the admin queue to 1 at allocation during the probe function and then puts it twice now: nvme_free_ctrl() blk_put_queue(ctrl->admin_q) // #1 ->free_ctrl() apple_nvme_free_ctrl() blk_put_queue(anv->ctrl.admin_q) // #2 Note that there is a commit 941f729 ("nvme-apple: remove an extra queue reference") which intended to drop taking an extra admin queue reference. Looks like at that moment it accidentally fixed a refcount leak, which existed since the driver's introduction. There were two ->get calls at driver's probe function and a single ->put inside apple_nvme_free_ctrl(). However now after commit 03b3bcd ("nvme: fix admin request_queue lifetime") the refcount is imbalanced again. Fix it by removing extra ->put call from apple_nvme_free_ctrl(). anv->dev and ctrl->dev point to the same device, so use ctrl->dev directly for simplification. Compile tested only. Found by Linux Verification Center (linuxtesting.org). Fixes: 03b3bcd ("nvme: fix admin request_queue lifetime") Cc: stable@vger.kernel.org Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru> Signed-off-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4af2e55 commit d525ecf

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

drivers/nvme/host/apple.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,11 +1208,7 @@ static int apple_nvme_get_address(struct nvme_ctrl *ctrl, char *buf, int size)
12081208

12091209
static void apple_nvme_free_ctrl(struct nvme_ctrl *ctrl)
12101210
{
1211-
struct apple_nvme *anv = ctrl_to_apple_nvme(ctrl);
1212-
1213-
if (anv->ctrl.admin_q)
1214-
blk_put_queue(anv->ctrl.admin_q);
1215-
put_device(anv->dev);
1211+
put_device(ctrl->dev);
12161212
}
12171213

12181214
static const struct nvme_ctrl_ops nvme_ctrl_ops = {

0 commit comments

Comments
 (0)