Skip to contentSkip to conversation

nvmet: fix NULL dereference when removing a referral

PATCH Applied Sagi Grimberg 4 participants 4 messages Apr 1, 2020 – Apr 2, 2020

Subsystems (2)
lore
Share & tools
lore

Sagi Grimberg

author maintainer
#0 lore raw

PATCH 1/1 nvmet: fix NULL dereference when removing a referral

When item release is called, the parent is already null. We need the parent to pass to nvmet_referral_disable so hook it in .disconnect_notify.

---
 drivers/nvme/target/configfs.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/nvme/target/configfs.c +9 -1
index 7aa10788b7c8..6705706265fa 100644
@@ -1098,12 +1098,19 @@ static struct configfs_attribute *nvmet_referral_attrs[] = {
 	NULL,
 };
 
-static void nvmet_referral_release(struct config_item *item)
+static void nvmet_referral_notify(struct config_group *group,
+	struct config_item *item)
 {
 	struct nvmet_port *parent = to_nvmet_port(item->ci_parent->ci_parent);
 	struct nvmet_port *port = to_nvmet_port(item);
 
 	nvmet_referral_disable(parent, port);
+}
+
+static void nvmet_referral_release(struct config_item *item)
+{
+	struct nvmet_port *port = to_nvmet_port(item);
+
 	kfree(port);
 }
 
@@ -1134,6 +1141,7 @@ static struct config_group *nvmet_referral_make(
 
 static struct configfs_group_operations nvmet_referral_group_ops = {
 	.make_group		= nvmet_referral_make,
+	.disconnect_notify	= nvmet_referral_notify,
 };
 
 static const struct config_item_type nvmet_referrals_type = {
Signature · 7 lines
2.20.1


_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Sagi Grimberg

When item release is called, the parent is already null. We need the parent to pass to nvmet_referral_disable so hook it in .disconnect_notify.

This patch seems to fix the problem, Tony please confirm.

Looks good to me for this issue.

_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#2 lore raw
Quoted 9 lines · Chaitanya Kulkarni
Quoted 6 lines · Sagi Grimberg

When item release is called, the parent is already null. We need the parent to pass to nvmet_referral_disable so hook it in .disconnect_notify.

This patch seems to fix the problem, Tony please confirm.

Confirmed

Thanks!

_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme