Merge tag 'mm-stable-2023-04-27-15-30' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-block.git] / kernel / printk / printk.c
index 1c71bb170e8596bc397e1605f7690774e0f9da9f..6a333adce3b33220d35aaa8501c496cabb2164db 100644 (file)
@@ -91,7 +91,7 @@ static DEFINE_MUTEX(console_mutex);
  * console_sem protects updates to console->seq and console_suspended,
  * and also provides serialization for console printing.
  */
-static DEFINE_SEMAPHORE(console_sem);
+static DEFINE_SEMAPHORE(console_sem, 1);
 HLIST_HEAD(console_list);
 EXPORT_SYMBOL_GPL(console_list);
 DEFINE_STATIC_SRCU(console_srcu);
@@ -732,7 +732,7 @@ static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from)
        size_t len = iov_iter_count(from);
        ssize_t ret = len;
 
-       if (!user || len > PRINTKRB_RECORD_MAX)
+       if (len > PRINTKRB_RECORD_MAX)
                return -EINVAL;
 
        /* Ignore when user logging is disabled. */
@@ -794,9 +794,6 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
        };
        ssize_t ret;
 
-       if (!user)
-               return -EBADF;
-
        ret = mutex_lock_interruptible(&user->lock);
        if (ret)
                return ret;
@@ -861,8 +858,6 @@ static loff_t devkmsg_llseek(struct file *file, loff_t offset, int whence)
        struct devkmsg_user *user = file->private_data;
        loff_t ret = 0;
 
-       if (!user)
-               return -EBADF;
        if (offset)
                return -ESPIPE;
 
@@ -895,9 +890,6 @@ static __poll_t devkmsg_poll(struct file *file, poll_table *wait)
        struct printk_info info;
        __poll_t ret = 0;
 
-       if (!user)
-               return EPOLLERR|EPOLLNVAL;
-
        poll_wait(file, &log_wait, wait);
 
        if (prb_read_valid_info(prb, atomic64_read(&user->seq), &info, NULL)) {
@@ -946,9 +938,6 @@ static int devkmsg_release(struct inode *inode, struct file *file)
 {
        struct devkmsg_user *user = file->private_data;
 
-       if (!user)
-               return 0;
-
        ratelimit_state_exit(&user->rs);
 
        mutex_destroy(&user->lock);