mirror of
https://github.com/systemd/systemd.git
synced 2025-02-14 05:57:40 +03:00
loop-util: fix memleak when fd is for a block device with non-zero offset or size
This commit is contained in:
parent
8ba24727c5
commit
d12c0f4cfe
@ -506,6 +506,7 @@ static int loop_device_make_internal(
|
||||
if (nr < 0)
|
||||
return -errno;
|
||||
|
||||
node = mfree(node);
|
||||
if (asprintf(&node, "/dev/loop%i", nr) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
@ -537,7 +538,6 @@ static int loop_device_make_internal(
|
||||
/* Now close the loop device explicitly. This will release any lock acquired by
|
||||
* attach_empty_file() or similar, while we sleep below. */
|
||||
loop = safe_close(loop);
|
||||
node = mfree(node);
|
||||
|
||||
/* Wait some random time, to make collision less likely. Let's pick a random time in the
|
||||
* range 0ms…250ms, linearly scaled by the number of failed attempts. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user