Skip to content

Commit 34df04d

Browse files
committed
macOS: Only call vnode_specrdev() when valid
1 parent 36fa21c commit 34df04d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

module/os/macos/spl/spl-vnode.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,15 @@ getf(int fd)
199199
/* Also grab vnode, so we can fish out the minor, for onexit */
200200
if (!file_vnode_withvid(fd, &vp, &vid)) {
201201
sfp->f_vnode = vp;
202-
if (vnode_vtype(vp) != VDIR) {
202+
203+
if (vnode_getwithref(vp) != 0) {
204+
file_drop(fd);
205+
return (NULL);
206+
}
207+
208+
enum vtype type;
209+
type = vnode_vtype(vp);
210+
if (type == VCHR || type == VBLK) {
203211
sfp->f_file = minor(vnode_specrdev(vp));
204212
}
205213
file_drop(fd);
@@ -242,6 +250,9 @@ releasef(int fd)
242250
if (!fp)
243251
return; // Not found
244252

253+
if (fp->f_vnode != NULL)
254+
vnode_put(fp->f_vnode);
255+
245256
/* Remove node from the list */
246257
mutex_enter(&spl_getf_lock);
247258
list_remove(&spl_getf_list, fp);

0 commit comments

Comments
 (0)