--- zzzz-none-000/linux-4.9.276/fs/pstore/pmsg.c 2021-07-20 14:21:16.000000000 +0000 +++ falcon-5530-750/linux-4.9.276/fs/pstore/pmsg.c 2023-04-05 08:19:02.000000000 +0000 @@ -34,7 +34,8 @@ return -EFAULT; mutex_lock(&pmsg_lock); - ret = psinfo->write_buf_user(PSTORE_TYPE_PMSG, 0, &id, 0, buf, 0, count, + ret = psinfo->write_buf_user(PSTORE_TYPE_PMSG, 0, &id, + iminor(file->f_inode), buf, 0, count, psinfo); mutex_unlock(&pmsg_lock); return ret ? ret : count; @@ -61,7 +62,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) { @@ -76,15 +77,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\n"); + 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);