--- zzzz-none-000/linux-5.4.213/fs/pstore/pmsg.c 2022-09-15 10:04:56.000000000 +0000 +++ miami-7690-761/linux-5.4.213/fs/pstore/pmsg.c 2024-05-29 11:20:02.000000000 +0000 @@ -23,6 +23,7 @@ pstore_record_init(&record, psinfo); record.type = PSTORE_TYPE_PMSG; record.size = count; + record.part = iminor(file->f_inode); /* check outside lock, page in any data. write_user also checks */ if (!access_ok(buf, count)) @@ -55,7 +56,7 @@ void pstore_register_pmsg(void) { - struct device *pmsg_device; + int i; pmsg_major = register_chrdev(0, PMSG_NAME, &pmsg_fops); if (pmsg_major < 0) { @@ -70,15 +71,23 @@ } pmsg_class->devnode = pmsg_devnode; - pmsg_device = device_create(pmsg_class, NULL, MKDEV(pmsg_major, 0), - NULL, "%s%d", PMSG_NAME, 0); - if (IS_ERR(pmsg_device)) { - pr_err("failed to create device\n"); - goto err_device; + /* allocate each pmsg device */ + for (i = 0; i < psinfo->num_pmsg; i++) { + struct device *pmsg_device; + + pmsg_device = + device_create(pmsg_class, NULL, MKDEV(pmsg_major, i), + NULL, "%s%d", PMSG_NAME, i); + if (IS_ERR(pmsg_device)) { + pr_err("failed to create device %s%d\n", PMSG_NAME, i); + goto err_device; + } } return; err_device: + for (i--; i >= 0; i--) + device_destroy(pmsg_class, MKDEV(pmsg_major, i)); class_destroy(pmsg_class); err_class: unregister_chrdev(pmsg_major, PMSG_NAME);