diff mbox

[2/8] mmc: debugfs: remove BUG_ON from mmc_ext_csd_open

Message ID 1478071479-12730-1-git-send-email-shawn.lin@rock-chips.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shawn Lin Nov. 2, 2016, 7:24 a.m. UTC
Return error value for file_operations callback instead
of triggering BUG_ON which is meaningless. Personally I
don't believe n != EXT_CSD_STR_LEN could happen. Anyway,
propagate the error to the caller.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/mmc/core/debugfs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Ulf Hansson Nov. 29, 2016, 12:41 p.m. UTC | #1
On 2 November 2016 at 08:24, Shawn Lin <shawn.lin@rock-chips.com> wrote:
> Return error value for file_operations callback instead
> of triggering BUG_ON which is meaningless. Personally I
> don't believe n != EXT_CSD_STR_LEN could happen. Anyway,
> propagate the error to the caller.
>
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>

Thanks, applied for next!

Kind regards
Uffe


> ---
>
>  drivers/mmc/core/debugfs.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
> index c8451ce..30623b8 100644
> --- a/drivers/mmc/core/debugfs.c
> +++ b/drivers/mmc/core/debugfs.c
> @@ -321,7 +321,11 @@ static int mmc_ext_csd_open(struct inode *inode, struct file *filp)
>         for (i = 0; i < 512; i++)
>                 n += sprintf(buf + n, "%02x", ext_csd[i]);
>         n += sprintf(buf + n, "\n");
> -       BUG_ON(n != EXT_CSD_STR_LEN);
> +
> +       if (n != EXT_CSD_STR_LEN) {
> +               err = -EINVAL;
> +               goto out_free;
> +       }
>
>         filp->private_data = buf;
>         kfree(ext_csd);
> --
> 2.3.7
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index c8451ce..30623b8 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -321,7 +321,11 @@  static int mmc_ext_csd_open(struct inode *inode, struct file *filp)
 	for (i = 0; i < 512; i++)
 		n += sprintf(buf + n, "%02x", ext_csd[i]);
 	n += sprintf(buf + n, "\n");
-	BUG_ON(n != EXT_CSD_STR_LEN);
+
+	if (n != EXT_CSD_STR_LEN) {
+		err = -EINVAL;
+		goto out_free;
+	}
 
 	filp->private_data = buf;
 	kfree(ext_csd);