hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/scsi/lpfc/lpfc_debugfs.c
....@@ -2159,10 +2159,13 @@
21592159 char mybuf[64];
21602160 char *pbuf;
21612161 int i;
2162
+ size_t bsize;
21622163
21632164 memset(mybuf, 0, sizeof(mybuf));
21642165
2165
- if (copy_from_user(mybuf, buf, nbytes))
2166
+ bsize = min(nbytes, (sizeof(mybuf) - 1));
2167
+
2168
+ if (copy_from_user(mybuf, buf, bsize))
21662169 return -EFAULT;
21672170 pbuf = &mybuf[0];
21682171
....@@ -2183,7 +2186,7 @@
21832186 qp->lock_conflict.wq_access = 0;
21842187 }
21852188 }
2186
- return nbytes;
2189
+ return bsize;
21872190 }
21882191 #endif
21892192
....@@ -5906,7 +5909,7 @@
59065909 phba->hba_debugfs_root,
59075910 phba,
59085911 &lpfc_debugfs_op_multixripools);
5909
- if (!phba->debug_multixri_pools) {
5912
+ if (IS_ERR(phba->debug_multixri_pools)) {
59105913 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
59115914 "0527 Cannot create debugfs multixripools\n");
59125915 goto debug_failed;
....@@ -5918,7 +5921,7 @@
59185921 debugfs_create_file(name, 0644,
59195922 phba->hba_debugfs_root,
59205923 phba, &lpfc_debugfs_ras_log);
5921
- if (!phba->debug_ras_log) {
5924
+ if (IS_ERR(phba->debug_ras_log)) {
59225925 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
59235926 "6148 Cannot create debugfs"
59245927 " ras_log\n");
....@@ -5939,7 +5942,7 @@
59395942 debugfs_create_file(name, S_IFREG | 0644,
59405943 phba->hba_debugfs_root,
59415944 phba, &lpfc_debugfs_op_lockstat);
5942
- if (!phba->debug_lockstat) {
5945
+ if (IS_ERR(phba->debug_lockstat)) {
59435946 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
59445947 "4610 Can't create debugfs lockstat\n");
59455948 goto debug_failed;
....@@ -6168,7 +6171,7 @@
61686171 debugfs_create_file(name, 0644,
61696172 vport->vport_debugfs_root,
61706173 vport, &lpfc_debugfs_op_scsistat);
6171
- if (!vport->debug_scsistat) {
6174
+ if (IS_ERR(vport->debug_scsistat)) {
61726175 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
61736176 "4611 Cannot create debugfs scsistat\n");
61746177 goto debug_failed;
....@@ -6179,7 +6182,7 @@
61796182 debugfs_create_file(name, 0644,
61806183 vport->vport_debugfs_root,
61816184 vport, &lpfc_debugfs_op_ioktime);
6182
- if (!vport->debug_ioktime) {
6185
+ if (IS_ERR(vport->debug_ioktime)) {
61836186 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
61846187 "0815 Cannot create debugfs ioktime\n");
61856188 goto debug_failed;