mmc: debugfs: remove BUG_ON from mmc_ext_csd_open
authorShawn Lin <shawn.lin@rock-chips.com>
Wed, 2 Nov 2016 07:24:39 +0000 (15:24 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:36:53 +0000 (15:36 -0500)
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>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
(cherry picked from commit a48ee3e65a9e7395e8bab86728fcdc81c30a89ca)

drivers/mmc/core/debugfs.c

index 01b35c0..ce86163 100644 (file)
@@ -331,7 +331,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);