s390/zcrypt: fix memleak at release
If a process is interrupted while accessing the crypto device and the
global ap_perms_mutex is contented, release() could return early and
fail to free related resources.
Fixes: 00fab2350e
("s390/zcrypt: multiple zcrypt device nodes support")
Cc: <stable@vger.kernel.org> # 4.19
Cc: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
This commit is contained in:
parent
7d194c2100
commit
388bb19be8
|
@ -522,8 +522,7 @@ static int zcrypt_release(struct inode *inode, struct file *filp)
|
||||||
if (filp->f_inode->i_cdev == &zcrypt_cdev) {
|
if (filp->f_inode->i_cdev == &zcrypt_cdev) {
|
||||||
struct zcdn_device *zcdndev;
|
struct zcdn_device *zcdndev;
|
||||||
|
|
||||||
if (mutex_lock_interruptible(&ap_perms_mutex))
|
mutex_lock(&ap_perms_mutex);
|
||||||
return -ERESTARTSYS;
|
|
||||||
zcdndev = find_zcdndev_by_devt(filp->f_inode->i_rdev);
|
zcdndev = find_zcdndev_by_devt(filp->f_inode->i_rdev);
|
||||||
mutex_unlock(&ap_perms_mutex);
|
mutex_unlock(&ap_perms_mutex);
|
||||||
if (zcdndev) {
|
if (zcdndev) {
|
||||||
|
|
Loading…
Reference in New Issue