lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri,  8 Apr 2022 16:42:21 +0800
From:   Enze Li <lienze@...inos.cn>
To:     phil@...lpotter.co.uk
Cc:     linux-kernel@...r.kernel.org, linux-block@...r.kernel.org,
        axboe@...nel.dk
Subject: [PATCH] cdrom: do not print info list when there is no cdrom device

There is no need to print a list of cdrom entries with blank info when
no cdrom device exists.  With this patch applied, we get:

================================================
$ cat /proc/sys/dev/cdrom/info
CD-ROM information, Id:cdrom.c 3.20 2003/12/17

No device found.

================================================

BTW, I also formatted the argument list of the cdrom_sysctl_info
function, using tabs instead of spaces.

Signed-off-by: Enze Li <lienze@...inos.cn>
---
 drivers/cdrom/cdrom.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 7bd10d63ddbe..33a51303f565 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -3507,7 +3507,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
 }
 
 static int cdrom_sysctl_info(struct ctl_table *ctl, int write,
-                           void *buffer, size_t *lenp, loff_t *ppos)
+			     void *buffer, size_t *lenp, loff_t *ppos)
 {
 	int pos;
 	char *info = cdrom_sysctl_settings.info;
@@ -3522,6 +3522,11 @@ static int cdrom_sysctl_info(struct ctl_table *ctl, int write,
 
 	pos = sprintf(info, "CD-ROM information, " VERSION "\n");
 	
+	if (list_empty(&cdrom_list)) {
+		scnprintf(info + pos, max_size - pos, "\nNo device found.\n");
+		goto doit;
+	}
+
 	if (cdrom_print_info("\ndrive name:\t", 0, info, &pos, CTL_NAME))
 		goto done;
 	if (cdrom_print_info("\ndrive speed:\t", 0, info, &pos, CTL_SPEED))
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ