hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/rapidio/devices/rio_mport_cdev.c
....@@ -1803,8 +1803,11 @@
18031803 rio_init_dbell_res(&rdev->riores[RIO_DOORBELL_RESOURCE],
18041804 0, 0xffff);
18051805 err = rio_add_device(rdev);
1806
- if (err)
1807
- goto cleanup;
1806
+ if (err) {
1807
+ put_device(&rdev->dev);
1808
+ return err;
1809
+ }
1810
+
18081811 rio_dev_get(rdev);
18091812
18101813 return 0;
....@@ -1900,10 +1903,6 @@
19001903
19011904 priv->md = chdev;
19021905
1903
- mutex_lock(&chdev->file_mutex);
1904
- list_add_tail(&priv->list, &chdev->file_list);
1905
- mutex_unlock(&chdev->file_mutex);
1906
-
19071906 INIT_LIST_HEAD(&priv->db_filters);
19081907 INIT_LIST_HEAD(&priv->pw_filters);
19091908 spin_lock_init(&priv->fifo_lock);
....@@ -1912,6 +1911,7 @@
19121911 sizeof(struct rio_event) * MPORT_EVENT_DEPTH,
19131912 GFP_KERNEL);
19141913 if (ret < 0) {
1914
+ put_device(&chdev->dev);
19151915 dev_err(&chdev->dev, DRV_NAME ": kfifo_alloc failed\n");
19161916 ret = -ENOMEM;
19171917 goto err_fifo;
....@@ -1922,6 +1922,9 @@
19221922 spin_lock_init(&priv->req_lock);
19231923 mutex_init(&priv->dma_lock);
19241924 #endif
1925
+ mutex_lock(&chdev->file_mutex);
1926
+ list_add_tail(&priv->list, &chdev->file_list);
1927
+ mutex_unlock(&chdev->file_mutex);
19251928
19261929 filp->private_data = priv;
19271930 goto out;