fd2devname(): Don't dereference NULL pointer

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
Jes Sorensen 2011-11-03 08:09:56 +11:00 committed by NeilBrown
parent 1471b8b14b
commit 7897de29b5
1 changed files with 4 additions and 2 deletions

View File

@ -2868,8 +2868,10 @@ static void fd2devname(int fd, char *name)
dname[rv] = '\0';
nm = strrchr(dname, '/');
nm++;
snprintf(name, MAX_RAID_SERIAL_LEN, "/dev/%s", nm);
if (nm) {
nm++;
snprintf(name, MAX_RAID_SERIAL_LEN, "/dev/%s", nm);
}
}
extern int scsi_get_serial(int fd, void *buf, size_t buf_len);