diff mbox

[3/8] block/floppy.c: handle blk_register_region() return value

Message ID 1446812535-10567-3-git-send-email-vishnu.ps@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

vishnu.ps Nov. 6, 2015, 12:22 p.m. UTC
This patch handles blk_register_region() return value.
Earlier blk_register_region() function doesn't handle error
cases, now it is added, so the callers of this function
should also handle it.

Verfied on X86 based ubuntu machine.
This patch depends on [PATCH 1/8] block/genhd.c: Add error handling

Signed-off-by: Vishnu Pratap Singh <vishnu.ps@samsung.com>
---
 drivers/block/floppy.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

kernel test robot Nov. 6, 2015, 12:50 p.m. UTC | #1
Hi Vishnu,

[auto build test ERROR on ide/master]
[also build test ERROR on v4.3]
[cannot apply to block/for-next next-20151106]

url:    https://github.com/0day-ci/linux/commits/Vishnu-Pratap-Singh/block-genhd-c-Add-error-handling/20151106-204249
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/ide.git master
config: x86_64-randconfig-x002-11051802 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/block/floppy.c: In function 'do_floppy_init':
>> drivers/block/floppy.c:4266:3: error: label 'out_fdc_region' used but not defined
      goto out_fdc_region;
      ^

vim +/out_fdc_region +4266 drivers/block/floppy.c

  4260	
  4261		fdc = 0;		/* reset fdc in case of unexpected interrupt */
  4262		err = floppy_grab_irq_and_dma();
  4263		if (err) {
  4264			cancel_delayed_work(&fd_timeout);
  4265			err = -EBUSY;
> 4266			goto out_fdc_region;
  4267		}
  4268	
  4269		/* initialise drive state */

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Grant Grundler Nov. 9, 2015, 11:44 p.m. UTC | #2
On Fri, Nov 6, 2015 at 4:22 AM, Vishnu Pratap Singh
<vishnu.ps@samsung.com> wrote:
> This patch handles blk_register_region() return value.
> Earlier blk_register_region() function doesn't handle error
> cases, now it is added, so the callers of this function
> should also handle it.
>
> Verfied on X86 based ubuntu machine.
> This patch depends on [PATCH 1/8] block/genhd.c: Add error handling
>
> Signed-off-by: Vishnu Pratap Singh <vishnu.ps@samsung.com>
> ---
>  drivers/block/floppy.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
> index 331363e..50802a6 100644
> --- a/drivers/block/floppy.c
> +++ b/drivers/block/floppy.c
> @@ -4219,8 +4219,10 @@ static int __init do_floppy_init(void)
>         if (err)
>                 goto out_unreg_blkdev;
>
> -       blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE,
> +       err = blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE,
>                             floppy_find, NULL, NULL);
> +       if (err)
> +               goto out_unreg_region;
>
>         for (i = 0; i < 256; i++)
>                 if (ITYPE(i))
> @@ -4250,7 +4252,7 @@ static int __init do_floppy_init(void)
>         if (fdc_state[0].address == -1) {
>                 cancel_delayed_work(&fd_timeout);
>                 err = -ENODEV;
> -               goto out_unreg_region;
> +               goto out_fdc_err;
>         }
>  #if N_FDC > 1
>         fdc_state[1].address = FDC2;
> @@ -4261,7 +4263,7 @@ static int __init do_floppy_init(void)
>         if (err) {
>                 cancel_delayed_work(&fd_timeout);
>                 err = -EBUSY;
> -               goto out_unreg_region;
> +               goto out_fdc_region;

Please drop this hunk.

>         }
>
>         /* initialise drive state */
> @@ -4357,8 +4359,9 @@ out_remove_drives:
>  out_release_dma:
>         if (atomic_read(&usage_count))
>                 floppy_release_irq_and_dma();
> -out_unreg_region:
> +out_fdc_err:
>         blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
> +out_unreg_region:

Nit: out_unreg_region should continue to be a label for the
unregister_region call.

My preference would be to add a new label here so something like
"goto out_driver_unregister" works.

I normally would ignore this sort of thing but this patch needs to be
reposted as V2 anyway.

cheers,
grant

>         platform_driver_unregister(&floppy_driver);
>  out_unreg_blkdev:
>         unregister_blkdev(FLOPPY_MAJOR, "fd");
> --
> 1.9.1
>
--
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/block/floppy.c b/drivers/block/floppy.c
index 331363e..50802a6 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4219,8 +4219,10 @@  static int __init do_floppy_init(void)
 	if (err)
 		goto out_unreg_blkdev;
 
-	blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE,
+	err = blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE,
 			    floppy_find, NULL, NULL);
+	if (err)
+		goto out_unreg_region;
 
 	for (i = 0; i < 256; i++)
 		if (ITYPE(i))
@@ -4250,7 +4252,7 @@  static int __init do_floppy_init(void)
 	if (fdc_state[0].address == -1) {
 		cancel_delayed_work(&fd_timeout);
 		err = -ENODEV;
-		goto out_unreg_region;
+		goto out_fdc_err;
 	}
 #if N_FDC > 1
 	fdc_state[1].address = FDC2;
@@ -4261,7 +4263,7 @@  static int __init do_floppy_init(void)
 	if (err) {
 		cancel_delayed_work(&fd_timeout);
 		err = -EBUSY;
-		goto out_unreg_region;
+		goto out_fdc_region;
 	}
 
 	/* initialise drive state */
@@ -4357,8 +4359,9 @@  out_remove_drives:
 out_release_dma:
 	if (atomic_read(&usage_count))
 		floppy_release_irq_and_dma();
-out_unreg_region:
+out_fdc_err:
 	blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
+out_unreg_region:
 	platform_driver_unregister(&floppy_driver);
 out_unreg_blkdev:
 	unregister_blkdev(FLOPPY_MAJOR, "fd");