diff mbox

Regression introduced with commit 2a0b4682e09d76 ("dm: convert dm_dev_internal.count from atomic_t to refcount_t)

Message ID 00c5e0f4-fe95-a7b4-bdc8-cd1bec442834@suse.de (mailing list archive)
State Superseded, archived
Delegated to: Mike Snitzer
Headers show

Commit Message

Hannes Reinecke Feb. 1, 2018, 2:54 p.m. UTC
Hi Mike,

yet another refcount_t regression:

        return 0;

is _NOT_ an equivalent modification.
If the second 'if' claus is not taken, the reference count is never
increased and the system goes 'boom'.

Will be sending a patch shortly.

Cheers,

Hannes
diff mbox

Patch

--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -451,15 +451,15 @@  int dm_get_device(struct dm_target *ti, const char
*path, fmode_t mode,
                        return r;
                }

-               atomic_set(&dd->count, 0);
+               refcount_set(&dd->count, 1);
                list_add(&dd->list, &t->devices);

        } else if (dd->dm_dev->mode != (mode | dd->dm_dev->mode)) {
                r = upgrade_mode(dd, mode, t->md);
                if (r)
                        return r;
+               refcount_inc(&dd->count);
        }
-       atomic_inc(&dd->count);

        *result = dd->dm_dev;