Source-Changes-HG archive

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

[src/trunk]: src/sys/kern disk(9): Fix missing unlock in error branch in prev...



details:   https://anonhg.NetBSD.org/src/rev/01d19943efe8
branches:  trunk
changeset: 374409:01d19943efe8
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Apr 22 11:58:01 2023 +0000

description:
disk(9): Fix missing unlock in error branch in previous change.

Reported-by: syzbot+870665adaf8911c0d94d%syzkaller.appspotmail.com@localhost
https://syzkaller.appspot.com/bug?id=a4ae17cf66b5bb999182ae77fd3c7ad9ad18c891

diffstat:

 sys/kern/subr_disk.c |  15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diffs (37 lines):

diff -r 333df0e279cf -r 01d19943efe8 sys/kern/subr_disk.c
--- a/sys/kern/subr_disk.c      Sat Apr 22 11:22:36 2023 +0000
+++ b/sys/kern/subr_disk.c      Sat Apr 22 11:58:01 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_disk.c,v 1.135 2023/04/21 18:30:04 riastradh Exp $        */
+/*     $NetBSD: subr_disk.c,v 1.136 2023/04/22 11:58:01 riastradh Exp $        */
 
 /*-
  * Copyright (c) 1996, 1997, 1999, 2000, 2009 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.135 2023/04/21 18:30:04 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.136 2023/04/22 11:58:01 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -535,10 +535,15 @@ disk_ioctl(struct disk *dk, dev_t dev, u
                int error;
 
                mutex_enter(&dk->dk_openlock);
-               if ((disk_info = dk->dk_info) == NULL)
-                       return ENOTSUP;
-               prop_object_retain(disk_info);
+               if ((disk_info = dk->dk_info) == NULL) {
+                       error = ENOTSUP;
+               } else {
+                       prop_object_retain(disk_info);
+                       error = 0;
+               }
                mutex_exit(&dk->dk_openlock);
+               if (error)
+                       return error;
 
                error = prop_dictionary_copyout_ioctl(data, cmd, disk_info);
                prop_object_release(disk_info);



Home | Main Index | Thread Index | Old Index