Unverified Commit a304375c authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!15503 ubi: Fix race condition between ctrl_cdev_ioctl and ubi_cdev_ioctl

parents 259b1112 f513004f
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -363,9 +363,6 @@ static ssize_t dev_attribute_show(struct device *dev,
	 * we still can use 'ubi->ubi_num'.
	 */
	ubi = container_of(dev, struct ubi_device, dev);
	ubi = ubi_get_device(ubi->ubi_num);
	if (!ubi)
		return -ENODEV;

	if (attr == &dev_eraseblock_size)
		ret = sprintf(buf, "%d\n", ubi->leb_size);
@@ -394,7 +391,6 @@ static ssize_t dev_attribute_show(struct device *dev,
	else
		ret = -EINVAL;

	ubi_put_device(ubi);
	return ret;
}

@@ -976,9 +972,6 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
			goto out_detach;
	}

	/* Make device "available" before it becomes accessible via sysfs */
	ubi_devices[ubi_num] = ubi;

	err = uif_init(ubi);
	if (err)
		goto out_detach;
@@ -1023,6 +1016,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
	wake_up_process(ubi->bgt_thread);
	spin_unlock(&ubi->wl_lock);

	ubi_devices[ubi_num] = ubi;
	ubi_notify_all(ubi, UBI_VOLUME_ADDED, NULL);
	return ubi_num;

@@ -1031,7 +1025,6 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
out_uif:
	uif_close(ubi);
out_detach:
	ubi_devices[ubi_num] = NULL;
	ubi_wl_close(ubi);
	ubi_free_internal_volumes(ubi);
	vfree(ubi->vtbl);
+1 −7
Original line number Diff line number Diff line
@@ -69,16 +69,11 @@ static ssize_t vol_attribute_show(struct device *dev,
{
	int ret;
	struct ubi_volume *vol = container_of(dev, struct ubi_volume, dev);
	struct ubi_device *ubi;

	ubi = ubi_get_device(vol->ubi->ubi_num);
	if (!ubi)
		return -ENODEV;
	struct ubi_device *ubi = vol->ubi;

	spin_lock(&ubi->volumes_lock);
	if (!ubi->volumes[vol->vol_id]) {
		spin_unlock(&ubi->volumes_lock);
		ubi_put_device(ubi);
		return -ENODEV;
	}
	/* Take a reference to prevent volume removal */
@@ -116,7 +111,6 @@ static ssize_t vol_attribute_show(struct device *dev,
	vol->ref_count -= 1;
	ubi_assert(vol->ref_count >= 0);
	spin_unlock(&ubi->volumes_lock);
	ubi_put_device(ubi);
	return ret;
}