Skip to content

Commit f0e656e

Browse files
sagigrimbergChristoph Hellwig
authored andcommitted
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 up to ->disconnect_notify. Reported-by: Tony Asleson <[email protected]> Signed-off-by: Sagi Grimberg <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 74e4d20 commit f0e656e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/nvme/target/configfs.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,12 +1098,19 @@ static struct configfs_attribute *nvmet_referral_attrs[] = {
10981098
NULL,
10991099
};
11001100

1101-
static void nvmet_referral_release(struct config_item *item)
1101+
static void nvmet_referral_notify(struct config_group *group,
1102+
struct config_item *item)
11021103
{
11031104
struct nvmet_port *parent = to_nvmet_port(item->ci_parent->ci_parent);
11041105
struct nvmet_port *port = to_nvmet_port(item);
11051106

11061107
nvmet_referral_disable(parent, port);
1108+
}
1109+
1110+
static void nvmet_referral_release(struct config_item *item)
1111+
{
1112+
struct nvmet_port *port = to_nvmet_port(item);
1113+
11071114
kfree(port);
11081115
}
11091116

@@ -1134,6 +1141,7 @@ static struct config_group *nvmet_referral_make(
11341141

11351142
static struct configfs_group_operations nvmet_referral_group_ops = {
11361143
.make_group = nvmet_referral_make,
1144+
.disconnect_notify = nvmet_referral_notify,
11371145
};
11381146

11391147
static const struct config_item_type nvmet_referrals_type = {

0 commit comments

Comments
 (0)