chore: check NULL before strlen (#13)

This commit is contained in:
Jim Ma 2023-05-19 15:26:12 +08:00 committed by GitHub
parent d7e0766776
commit eaf7be9a14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -703,7 +703,7 @@ static int handle_hdio_drive_cmd_ioctl(struct block_device *bdev, fmode_t mode,
// use the real serial if it's not empty, other wise use the disk name
char * disk_serial;
disk_serial = rp_fetch_block_serial(bdev->bd_disk->disk_name);
if (strlen(disk_serial) < 3) {
if (disk_serial == NULL || strlen(disk_serial) < 3) {
disk_serial = bdev->bd_disk->disk_name;
}