diff mbox series

scsi: lpfc: Fix Fix the NULL vs IS_ERR() bug for debugfs_create_file()

Message ID 20230906030809.2847970-1-ruanjinjie@huawei.com
State New
Headers show
Series scsi: lpfc: Fix Fix the NULL vs IS_ERR() bug for debugfs_create_file() | expand

Commit Message

Jinjie Ruan Sept. 6, 2023, 3:08 a.m. UTC
Since debugfs_create_file() return ERR_PTR and never return NULL, so use
IS_ERR() to check it instead of checking NULL.

Fixes: 2fcbc569b9f5 ("scsi: lpfc: Make debugfs ktime stats generic for NVME and SCSI")
Fixes: 4c47efc140fa ("scsi: lpfc: Move SCSI and NVME Stats to hardware queue structures")
Fixes: 6a828b0f6192 ("scsi: lpfc: Support non-uniform allocation of MSIX vectors to hardware queues")
Fixes: 95bfc6d8ad86 ("scsi: lpfc: Make FW logging dynamically configurable")
Fixes: 9f77870870d8 ("scsi: lpfc: Add debugfs support for cm framework buffers")
Fixes: c490850a0947 ("scsi: lpfc: Adapt partitioned XRI lists to efficient sharing")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/scsi/lpfc/lpfc_debugfs.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Justin Tee Sept. 6, 2023, 5:07 p.m. UTC | #1
Hi Jinjie,

The title of this patch has the word "Fix" twice, but the change
itself looks fine.

Reviewed-by: Justin Tee <justin.tee@broadcom.com>


On Tue, Sep 5, 2023 at 8:08 PM Jinjie Ruan <ruanjinjie@huawei.com> wrote:
>
> Since debugfs_create_file() return ERR_PTR and never return NULL, so use
> IS_ERR() to check it instead of checking NULL.
>
> Fixes: 2fcbc569b9f5 ("scsi: lpfc: Make debugfs ktime stats generic for NVME and SCSI")
> Fixes: 4c47efc140fa ("scsi: lpfc: Move SCSI and NVME Stats to hardware queue structures")
> Fixes: 6a828b0f6192 ("scsi: lpfc: Support non-uniform allocation of MSIX vectors to hardware queues")
> Fixes: 95bfc6d8ad86 ("scsi: lpfc: Make FW logging dynamically configurable")
> Fixes: 9f77870870d8 ("scsi: lpfc: Add debugfs support for cm framework buffers")
> Fixes: c490850a0947 ("scsi: lpfc: Adapt partitioned XRI lists to efficient sharing")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
>  drivers/scsi/lpfc/lpfc_debugfs.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
> index 7f9b221e7c34..ea9b42225e62 100644
> --- a/drivers/scsi/lpfc/lpfc_debugfs.c
> +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
> @@ -6073,7 +6073,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
>                                             phba->hba_debugfs_root,
>                                             phba,
>                                             &lpfc_debugfs_op_multixripools);
> -               if (!phba->debug_multixri_pools) {
> +               if (IS_ERR(phba->debug_multixri_pools)) {
>                         lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
>                                          "0527 Cannot create debugfs multixripools\n");
>                         goto debug_failed;
> @@ -6085,7 +6085,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
>                         debugfs_create_file(name, S_IFREG | 0644,
>                                             phba->hba_debugfs_root,
>                                             phba, &lpfc_cgn_buffer_op);
> -               if (!phba->debug_cgn_buffer) {
> +               if (IS_ERR(phba->debug_cgn_buffer)) {
>                         lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
>                                          "6527 Cannot create debugfs "
>                                          "cgn_buffer\n");
> @@ -6098,7 +6098,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
>                         debugfs_create_file(name, S_IFREG | 0644,
>                                             phba->hba_debugfs_root,
>                                             phba, &lpfc_rx_monitor_op);
> -               if (!phba->debug_rx_monitor) {
> +               if (IS_ERR(phba->debug_rx_monitor)) {
>                         lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
>                                          "6528 Cannot create debugfs "
>                                          "rx_monitor\n");
> @@ -6111,7 +6111,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
>                         debugfs_create_file(name, 0644,
>                                             phba->hba_debugfs_root,
>                                             phba, &lpfc_debugfs_ras_log);
> -               if (!phba->debug_ras_log) {
> +               if (IS_ERR(phba->debug_ras_log)) {
>                         lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
>                                          "6148 Cannot create debugfs"
>                                          " ras_log\n");
> @@ -6132,7 +6132,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
>                         debugfs_create_file(name, S_IFREG | 0644,
>                                             phba->hba_debugfs_root,
>                                             phba, &lpfc_debugfs_op_lockstat);
> -               if (!phba->debug_lockstat) {
> +               if (IS_ERR(phba->debug_lockstat)) {
>                         lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
>                                          "4610 Can't create debugfs lockstat\n");
>                         goto debug_failed;
> @@ -6358,7 +6358,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
>                 debugfs_create_file(name, 0644,
>                                     vport->vport_debugfs_root,
>                                     vport, &lpfc_debugfs_op_scsistat);
> -       if (!vport->debug_scsistat) {
> +       if (IS_ERR(vport->debug_scsistat)) {
>                 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
>                                  "4611 Cannot create debugfs scsistat\n");
>                 goto debug_failed;
> @@ -6369,7 +6369,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
>                 debugfs_create_file(name, 0644,
>                                     vport->vport_debugfs_root,
>                                     vport, &lpfc_debugfs_op_ioktime);
> -       if (!vport->debug_ioktime) {
> +       if (IS_ERR(vport->debug_ioktime)) {
>                 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
>                                  "0815 Cannot create debugfs ioktime\n");
>                 goto debug_failed;
> --
> 2.34.1
>
Martin K. Petersen Sept. 14, 2023, 1:40 a.m. UTC | #2
On Wed, 06 Sep 2023 11:08:09 +0800, Jinjie Ruan wrote:

> Since debugfs_create_file() return ERR_PTR and never return NULL, so use
> IS_ERR() to check it instead of checking NULL.
> 
> 

Applied to 6.6/scsi-fixes, thanks!

[1/1] scsi: lpfc: Fix Fix the NULL vs IS_ERR() bug for debugfs_create_file()
      https://git.kernel.org/mkp/scsi/c/7dcc683db363
diff mbox series

Patch

diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 7f9b221e7c34..ea9b42225e62 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -6073,7 +6073,7 @@  lpfc_debugfs_initialize(struct lpfc_vport *vport)
 					    phba->hba_debugfs_root,
 					    phba,
 					    &lpfc_debugfs_op_multixripools);
-		if (!phba->debug_multixri_pools) {
+		if (IS_ERR(phba->debug_multixri_pools)) {
 			lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
 					 "0527 Cannot create debugfs multixripools\n");
 			goto debug_failed;
@@ -6085,7 +6085,7 @@  lpfc_debugfs_initialize(struct lpfc_vport *vport)
 			debugfs_create_file(name, S_IFREG | 0644,
 					    phba->hba_debugfs_root,
 					    phba, &lpfc_cgn_buffer_op);
-		if (!phba->debug_cgn_buffer) {
+		if (IS_ERR(phba->debug_cgn_buffer)) {
 			lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
 					 "6527 Cannot create debugfs "
 					 "cgn_buffer\n");
@@ -6098,7 +6098,7 @@  lpfc_debugfs_initialize(struct lpfc_vport *vport)
 			debugfs_create_file(name, S_IFREG | 0644,
 					    phba->hba_debugfs_root,
 					    phba, &lpfc_rx_monitor_op);
-		if (!phba->debug_rx_monitor) {
+		if (IS_ERR(phba->debug_rx_monitor)) {
 			lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
 					 "6528 Cannot create debugfs "
 					 "rx_monitor\n");
@@ -6111,7 +6111,7 @@  lpfc_debugfs_initialize(struct lpfc_vport *vport)
 			debugfs_create_file(name, 0644,
 					    phba->hba_debugfs_root,
 					    phba, &lpfc_debugfs_ras_log);
-		if (!phba->debug_ras_log) {
+		if (IS_ERR(phba->debug_ras_log)) {
 			lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
 					 "6148 Cannot create debugfs"
 					 " ras_log\n");
@@ -6132,7 +6132,7 @@  lpfc_debugfs_initialize(struct lpfc_vport *vport)
 			debugfs_create_file(name, S_IFREG | 0644,
 					    phba->hba_debugfs_root,
 					    phba, &lpfc_debugfs_op_lockstat);
-		if (!phba->debug_lockstat) {
+		if (IS_ERR(phba->debug_lockstat)) {
 			lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
 					 "4610 Can't create debugfs lockstat\n");
 			goto debug_failed;
@@ -6358,7 +6358,7 @@  lpfc_debugfs_initialize(struct lpfc_vport *vport)
 		debugfs_create_file(name, 0644,
 				    vport->vport_debugfs_root,
 				    vport, &lpfc_debugfs_op_scsistat);
-	if (!vport->debug_scsistat) {
+	if (IS_ERR(vport->debug_scsistat)) {
 		lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
 				 "4611 Cannot create debugfs scsistat\n");
 		goto debug_failed;
@@ -6369,7 +6369,7 @@  lpfc_debugfs_initialize(struct lpfc_vport *vport)
 		debugfs_create_file(name, 0644,
 				    vport->vport_debugfs_root,
 				    vport, &lpfc_debugfs_op_ioktime);
-	if (!vport->debug_ioktime) {
+	if (IS_ERR(vport->debug_ioktime)) {
 		lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
 				 "0815 Cannot create debugfs ioktime\n");
 		goto debug_failed;