WIP: fix log->mutex + misc_mtx ab-ba deadlock sandbox/lstelmach/deadlock
authorŁukasz Stelmach <l.stelmach@samsung.com>
Mon, 24 Jan 2022 13:53:39 +0000 (14:53 +0100)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Mon, 24 Jan 2022 13:54:24 +0000 (14:54 +0100)
Change-Id: Ibaab2947638997dca82c0e47146f77ce0f1bee57
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
kernel/logger.c

index 8b2cda9d22c94c3a369dc7c87233dd6e897174da..cf5dd8a9fc13c740b83726843f7e723e43896dde 100644 (file)
@@ -689,11 +689,12 @@ static ssize_t logger_aio_write(struct kiocb *iocb, const struct iovec *iov,
                if (writer->owner != current->group_leader) {
                        struct file *nfile;
 
+                       mutex_unlock(&log->mutex);
                        nfile = make_new_file(file);
                        if (IS_ERR(nfile)) {
-                               mutex_unlock(&log->mutex);
                                return PTR_ERR(nfile);
                        }
+                       mutex_lock(&log->mutex);
 
                        file = nfile;
                        writer = file->private_data;
@@ -874,11 +875,12 @@ static ssize_t logger_write_iter(struct kiocb *iocb, struct iov_iter *from)
                if (writer->owner != current->group_leader) {
                        struct file *nfile;
 
+                       mutex_unlock(&log->mutex);
                        nfile = make_new_file(file);
                        if (IS_ERR(nfile)) {
-                               mutex_unlock(&log->mutex);
                                return PTR_ERR(nfile);
                        }
+                       mutex_lock(&log->mutex);
 
                        file = nfile;
                        writer = file->private_data;