Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5004813rwl; Tue, 28 Mar 2023 14:47:39 -0700 (PDT) X-Google-Smtp-Source: AKy350YYYBIB7qIsa42JX8/VzOcR0KbUcTN2PAQXj1LmdT62aBxilsUhdeDxaJbJT6FhiEp+GZca X-Received: by 2002:aa7:9609:0:b0:62d:7f6:cf1 with SMTP id q9-20020aa79609000000b0062d07f60cf1mr10054271pfg.3.1680040058846; Tue, 28 Mar 2023 14:47:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680040058; cv=none; d=google.com; s=arc-20160816; b=QpHSVvDnOlZmT0VSCzGzJeTQqlN2FpK/MZabZquXDDyoWFcIOEpMiOE5zteLN+mXxk xbKgHSc/6bIGB3+HwbsjlSDLkkZbvsMvd3VF67jI0L0EHy/te5830eF5HWEda8qJtdmJ /YIgIMplwltPCB/GGqCpnhbzbNzL5OoDRJqClU65aOSUckhuulHB/etx3vV6lcSpZeHN s+igrLemYc2qAZPr47KGVnApsTRHiC1lSlRwNE41WMD8sVue2HJlY8XwfQUhxDhFYKlF e7mSRN6v0IIi3YM1wyNGFUPK9vDl+IkA/UfN8VSunMK2XgELFbXdoJu2TP1sSHbrD/b3 nmyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :user-agent:message-id:date:cc:from:subject:dkim-signature :dkim-filter; bh=5B2i+VHjiu+ubqKoN1kwXRD7hgJa5VH8yOvgkhGgb4o=; b=fE+AvsyAk94S+as7CrCb8kwxGyTE8yObhSbCykirdTlR4md0UHJ7NW5a0G9z+BrsMZ 0ihpbjrMSoUkGIvYDvuRXcUR4zMZuz1bVFAmu9xzRlTDr1Y5MCaQJ0vV9RI+lu5LQTjY K76w5rqg8es/uCGb3cnM7vfmhbB5ASV3quwCEwAaha+ZubHC23gkOQgxd9RFKZcVwG86 JDFeTxk8f44GaRVn31hXyucsVqgMsA6elA/zTzY6iZN4lFzTyGRwuTsgUBU5OM2LrwXH 6jd6Kw/0q4vHHi8bsGjOJBltLyDInbU1cRYm6JLqjarNZ4kaozyyJupMGOvpwmHXue1h faig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=bVJy7siy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q7-20020a63d607000000b00513522ea60asi5650639pgg.615.2023.03.28.14.47.26; Tue, 28 Mar 2023 14:47:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=bVJy7siy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229825AbjC1Vq6 (ORCPT + 99 others); Tue, 28 Mar 2023 17:46:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229729AbjC1Vq4 (ORCPT ); Tue, 28 Mar 2023 17:46:56 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CCD6B1712 for ; Tue, 28 Mar 2023 14:46:55 -0700 (PDT) Received: from skinsburskii.localdomain (c-67-170-100-148.hsd1.wa.comcast.net [67.170.100.148]) by linux.microsoft.com (Postfix) with ESMTPSA id E93B120FDA86; Tue, 28 Mar 2023 14:46:54 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E93B120FDA86 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680040015; bh=5B2i+VHjiu+ubqKoN1kwXRD7hgJa5VH8yOvgkhGgb4o=; h=Subject:From:Cc:Date:From; b=bVJy7siypq98zpsZ4UGlciijsRdOt02pMb0+1UGTYnBeNPJjOKZcj6De5nKHMKSbb kMsSfT15YbCSdocn+371A517/9UGdM0vGS1YFLUPO9zyx2tUvjC7Fqpu1TjRMuXPW8 O7RPTDaweZIwHJXxcn4cvJAi0mxioF+qFB0FFfXg= Subject: [PATCH] printk: Remove obsoleted check for non-existent "user" object From: Stanislav Kinsburskii Cc: Stanislav Kinsburskii , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , John Ogness , linux-kernel@vger.kernel.org Date: Mon, 20 Mar 2023 00:02:01 -0700 Message-ID: <167929571877.2810.9926967619100618792.stgit@skinsburskii.localdomain> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-14.6 required=5.0 tests=DATE_IN_PAST_96_XX, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH, MISSING_HEADERS,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stanislav Kinsburskii The original check for non-null "user" object was introduced by commit e11fea92e13f ("kmsg: export printk records to the /dev/kmsg interface") when "user" could be NULL if /dev/ksmg was opened for writing. Subsequent change 750afe7babd1 ("printk: add kernel parameter to control writes to /dev/kmsg") made "user" context required for files opened for write, but didn't remove now redundant checks for it to be non-NULL. This patch removes the dead code while preserving the current logic. Signed-off-by: Stanislav Kinsburskii CC: Petr Mladek CC: Sergey Senozhatsky CC: Steven Rostedt CC: John Ogness CC: linux-kernel@vger.kernel.org --- kernel/printk/printk.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index fd0c9f913940..9644f6e5bf15 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -730,7 +730,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. */ @@ -792,9 +792,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; @@ -859,8 +856,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; @@ -893,9 +888,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)) { @@ -944,9 +936,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);