Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/dm dm: Fix error handling in dmioctl()



details:   https://anonhg.NetBSD.org/src/rev/b1717d3fbd83
branches:  trunk
changeset: 466042:b1717d3fbd83
user:      tkusumi <tkusumi%NetBSD.org@localhost>
date:      Mon Dec 09 15:54:59 2019 +0000

description:
dm: Fix error handling in dmioctl()

Looks like cleanup_exit label is in a wrong place.
Should skip prop_dictionary_copyout_ioctl() on error.

diffstat:

 sys/dev/dm/device-mapper.c |  10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diffs (42 lines):

diff -r 962edf6e7919 -r b1717d3fbd83 sys/dev/dm/device-mapper.c
--- a/sys/dev/dm/device-mapper.c        Mon Dec 09 15:37:26 2019 +0000
+++ b/sys/dev/dm/device-mapper.c        Mon Dec 09 15:54:59 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: device-mapper.c,v 1.47 2019/12/07 16:13:39 tkusumi Exp $ */
+/*        $NetBSD: device-mapper.c,v 1.48 2019/12/09 15:54:59 tkusumi Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -355,20 +355,18 @@
        int r;
        prop_dictionary_t dm_dict_in;
 
-       r = 0;
-
        aprint_debug("dmioctl called\n");
        KASSERT(data != NULL);
 
        if ((r = disk_ioctl_switch(dev, cmd, data)) == ENOTTY) {
-               struct plistref *pref = (struct plistref *) data;
+               struct plistref *pref = (struct plistref *)data;
 
                /* Check if we were called with NETBSD_DM_IOCTL ioctl
                   otherwise quit. */
                if ((r = dm_ioctl_switch(cmd)) != 0)
                        return r;
 
-               if((r = prop_dictionary_copyin_ioctl(pref, cmd, &dm_dict_in))
+               if ((r = prop_dictionary_copyin_ioctl(pref, cmd, &dm_dict_in))
                    != 0)
                        return r;
 
@@ -379,8 +377,8 @@
                if ((r = dm_cmd_to_fun(dm_dict_in)) != 0)
                        goto cleanup_exit;
 
+               r = prop_dictionary_copyout_ioctl(pref, cmd, dm_dict_in);
 cleanup_exit:
-               r = prop_dictionary_copyout_ioctl(pref, cmd, dm_dict_in);
                prop_object_release(dm_dict_in);
        }
 



Home | Main Index | Thread Index | Old Index