From owner-p4-projects@FreeBSD.ORG Mon Oct 30 23:31:16 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B3A2616A4D4; Mon, 30 Oct 2006 23:31:15 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6D1B116A416 for ; Mon, 30 Oct 2006 23:31:15 +0000 (UTC) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 706BD43D67 for ; Mon, 30 Oct 2006 23:31:03 +0000 (GMT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k9UNV09C099672 for ; Mon, 30 Oct 2006 23:31:00 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k9UNV02n099612 for perforce@freebsd.org; Mon, 30 Oct 2006 23:31:00 GMT (envelope-from marcel@freebsd.org) Date: Mon, 30 Oct 2006 23:31:00 GMT Message-Id: <200610302331.k9UNV02n099612@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Cc: Subject: PERFORCE change 108785 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Oct 2006 23:31:16 -0000 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