diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 5bdf923294a5d610429581c83e558529f7d40b62..d816ae7db205bc18be9c13ab7c1c80085179fd70 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1584,6 +1584,15 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info) } } else { nbd = idr_find(&nbd_index_idr, index); + if (!nbd) { + ret = nbd_dev_add(index); + if (ret < 0) { + mutex_unlock(&nbd_index_mutex); + printk(KERN_ERR "nbd: failed to add new device\n"); + return ret; + } + nbd = idr_find(&nbd_index_idr, index); + } } if (!nbd) { printk(KERN_ERR "nbd: couldn't find device at index %d\n",