All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lei Chen" <lei.chen@smartx.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: megaraid_sas: Fix debugfs setup error handling
Date: Wed, 07 Oct 2026 14:28:16 +0000	[thread overview]
Message-ID: <sashiko-outbox-163098@kernel.org> (raw)
In-Reply-To: <20261007141753.416672-1-lei.chen@smartx.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] scsi: megaraid_sas: debugfs API violation by checking return values and logging errors
--

commit 3a04787b7089e752e49721091a64cf2824d3811c
Author: Lei Chen <lei.chen@smartx.com>

scsi: megaraid_sas: Fix debugfs setup error handling

This commit updates the debugfs setup in megaraid_sas to handle error
pointers by adding IS_ERR_OR_NULL checks. It also ensures that the
per-adapter directory is cleaned up and its pointer cleared if the raidmap
file creation fails.

> diff --git a/drivers/scsi/megaraid/megaraid_sas_debugfs.c b/drivers/scsi/megaraid/megaraid_sas_debugfs.c
> index 81698cd83f5ae..556e01fc25e8e 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_debugfs.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_debugfs.c
> @@ -126,13 +126,16 @@ megasas_setup_debugfs(struct megasas_instance *instance)

[ ... ]

>  		if (!instance->debugfs_root) {
>  			instance->debugfs_root =
>  				debugfs_create_dir(name, megasas_debugfs_root);
> -			if (!instance->debugfs_root) {
> +			if (IS_ERR_OR_NULL(instance->debugfs_root)) {
>  				dev_err(&instance->pdev->dev,
>  					"Cannot create per adapter debugfs directory\n");

[Severity: Low]
Does this violate the debugfs API guidelines?

The debugfs guidelines recommend that drivers should not check the return
values of debugfs_create_*() functions.

If debugfs fails, such as due to memory constraints or runtime parameters,
these IS_ERR_OR_NULL() checks in megasas_setup_debugfs() will evaluate to
true and print a dev_err to the kernel log, creating spurious error logs
and adding unnecessary error-handling complexity.

>  				return;
> @@ -144,10 +147,11 @@ megasas_setup_debugfs(struct megasas_instance *instance)
>  			debugfs_create_file(name, S_IRUGO,
>  					    instance->debugfs_root, instance,
>  					    &megasas_debugfs_raidmap_fops);
> -		if (!instance->raidmap_dump) {
> +		if (IS_ERR_OR_NULL(instance->raidmap_dump)) {
>  			dev_err(&instance->pdev->dev,
>  				"Cannot create raidmap debugfs file\n");

[Severity: Low]
Could this be simplified by removing the error check entirely?

Similar to the directory creation above, checking the return value of
debugfs_create_file() here in megasas_setup_debugfs() is generally
discouraged. Removing these checks completely might align better with the
subsystem guidelines.

>  			debugfs_remove(instance->debugfs_root);
> +			instance->debugfs_root = NULL;
>  			return;
>  		}
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261007141753.416672-1-lei.chen@smartx.com?part=1

  reply	other threads:[~2026-10-07 14:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07 14:17 [PATCH] scsi: megaraid_sas: Fix debugfs setup error handling Lei Chen
2026-10-07 14:28 ` sashiko-bot [this message]
2026-10-08  2:34 ` [PATCH v2] scsi: megaraid_sas: Simplify debugfs setup Lei Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-163098@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=lei.chen@smartx.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.