All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Teigland <teigland@sourceware.org>
To: lvm-devel@redhat.com
Subject: main - pvscan: fix error message for invalid devname
Date: Wed,  1 Dec 2021 20:39:45 +0000 (GMT)	[thread overview]
Message-ID: <20211201203945.3D975385840C@sourceware.org> (raw)

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c42a05c3ec8608e438fca435e3cbe6d306af80c6
Commit:        c42a05c3ec8608e438fca435e3cbe6d306af80c6
Parent:        05d9a013516f23e27b04b6933705c6ae45f9f5b2
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Wed Dec 1 14:36:40 2021 -0600
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Wed Dec 1 14:38:17 2021 -0600

pvscan: fix error message for invalid devname

uninitialized name buffer used in message.
fixes "pvs_online: include devname in pvid files"
---
 lib/device/dev-cache.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index b5f355484..825e348b4 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -2102,7 +2102,7 @@ int setup_devices_for_online_autoactivation(struct cmd_context *cmd)
 static char *_get_devname_from_devno(struct cmd_context *cmd, dev_t devno)
 {
 	char path[PATH_MAX];
-	char devname[PATH_MAX];
+	char devname[PATH_MAX] = { 0 };
 	char namebuf[NAME_LEN];
 	char line[1024];
 	int major = MAJOR(devno);
@@ -2114,6 +2114,9 @@ static char *_get_devname_from_devno(struct cmd_context *cmd, dev_t devno)
 	struct dirent *dirent;
 	FILE *fp;
 
+	if (!devno)
+		return NULL;
+
 	/*
 	 * $ ls /sys/dev/block/8:0/device/block/
 	 * sda
@@ -2251,6 +2254,8 @@ struct device *setup_dev_in_dev_cache(struct cmd_context *cmd, dev_t devno, cons
 	if (devname) {
 		if (stat(devname, &buf) < 0) {
 			log_error("Cannot access device %s for %d:%d.", devname, major, minor);
+			if (!devno)
+				return_NULL;
 			if (!(devname = _get_devname_from_devno(cmd, devno))) {
 				log_error("No device name found from %d:%d.", major, minor);
 				return_NULL;



                 reply	other threads:[~2021-12-01 20:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211201203945.3D975385840C@sourceware.org \
    --to=teigland@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.