Date: Mon, 30 Oct 2006 23:31:00 GMT From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 108785 for review Message-ID: <200610302331.k9UNV02n099612@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=108785 Change 108785 by marcel@marcel_cluster on 2006/10/30 23:30:02 Fix devopen(). Clear f->f_devdata on failure so that devclose() doesn't try to free() an already freed allocation. While here, improve style. Affected files ... .. //depot/projects/ia64/sys/boot/common/devopen.c#3 edit Differences ... ==== //depot/projects/ia64/sys/boot/common/devopen.c#3 (text+ko) ==== @@ -35,20 +35,25 @@ int devopen(struct open_file *f, const char *fname, const char **file) { - struct devdesc *dev; - int result; + struct devdesc *dev; + int result; + + result = archsw.arch_getdev((void **)&dev, fname, file); + if (result) + return (result); - if ((result = archsw.arch_getdev((void *)&dev, fname, file)) == 0) { /* get the device */ - /* point to device-specific data so that device open can use it */ - f->f_devdata = dev; - if ((result = dev->d_dev->dv_open(f, dev)) == 0) { /* try to open it */ - /* reference the devsw entry from the open_file structure */ - f->f_dev = dev->d_dev; - } else { - free(dev); /* release the device descriptor */ - } + /* point to device-specific data so that device open can use it */ + f->f_devdata = dev; + result = dev->d_dev->dv_open(f, dev); + if (result != 0) { + f->f_devdata = NULL; + free(dev); + return (result); } - return(result); + + /* reference the devsw entry from the open_file structure */ + f->f_dev = dev->d_dev; + return (0); } int
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610302331.k9UNV02n099612>