Print this page
10703 smatch unreachable code checking needs reworking
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright 2018 Joyent, Inc.
  26  */
  27 
  28 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  29 /*        All Rights Reserved   */
  30 
  31 /*
  32  * University Copyright- Copyright (c) 1982, 1986, 1988
  33  * The Regents of the University of California
  34  * All Rights Reserved
  35  *
  36  * University Acknowledgment- Portions of this document are derived from
  37  * software developed by the University of California, Berkeley, and its
  38  * contributors.
  39  */
  40 
  41 /*
  42  * VM - segment of a mapped device.
  43  *
  44  * This segment driver is used when mapping character special devices.
  45  */


3971          * if cookie is NULL, no effects on the system
3972          */
3973         if (cookie == NULL)
3974                 return;
3975 
3976         cp = (struct ddi_umem_cookie *)cookie;
3977 
3978         switch (cp->type) {
3979         case KMEM_PAGEABLE :
3980                 ASSERT(cp->cvaddr != NULL && cp->size != 0);
3981                 /*
3982                  * Check if there are still any pending faults on the cookie
3983                  * while the driver is deleting it,
3984                  * XXX - could change to an ASSERT but wont catch errant drivers
3985                  */
3986                 mutex_enter(&cp->lock);
3987                 if (cp->locked) {
3988                         mutex_exit(&cp->lock);
3989                         panic("ddi_umem_free for cookie with pending faults %p",
3990                             (void *)cp);
3991                         return;
3992                 }
3993 
3994                 segkp_release(segkp, cp->cvaddr);
3995 
3996                 /*
3997                  * release mutex associated with this cookie.
3998                  */
3999                 mutex_destroy(&cp->lock);
4000                 break;
4001         case KMEM_NON_PAGEABLE :
4002                 ASSERT(cp->cvaddr != NULL && cp->size != 0);
4003                 devmap_umem_free_np(cp->cvaddr, cp->size);
4004                 break;
4005         case UMEM_TRASH :
4006                 break;
4007         case UMEM_LOCKED :
4008                 /* Callers should use ddi_umem_unlock for this type */
4009                 ddi_umem_unlock(cookie);
4010                 /* Frees the cookie too */
4011                 return;




   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright 2019 Joyent, Inc.
  26  */
  27 
  28 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  29 /*        All Rights Reserved   */
  30 
  31 /*
  32  * University Copyright- Copyright (c) 1982, 1986, 1988
  33  * The Regents of the University of California
  34  * All Rights Reserved
  35  *
  36  * University Acknowledgment- Portions of this document are derived from
  37  * software developed by the University of California, Berkeley, and its
  38  * contributors.
  39  */
  40 
  41 /*
  42  * VM - segment of a mapped device.
  43  *
  44  * This segment driver is used when mapping character special devices.
  45  */


3971          * if cookie is NULL, no effects on the system
3972          */
3973         if (cookie == NULL)
3974                 return;
3975 
3976         cp = (struct ddi_umem_cookie *)cookie;
3977 
3978         switch (cp->type) {
3979         case KMEM_PAGEABLE :
3980                 ASSERT(cp->cvaddr != NULL && cp->size != 0);
3981                 /*
3982                  * Check if there are still any pending faults on the cookie
3983                  * while the driver is deleting it,
3984                  * XXX - could change to an ASSERT but wont catch errant drivers
3985                  */
3986                 mutex_enter(&cp->lock);
3987                 if (cp->locked) {
3988                         mutex_exit(&cp->lock);
3989                         panic("ddi_umem_free for cookie with pending faults %p",
3990                             (void *)cp);

3991                 }
3992 
3993                 segkp_release(segkp, cp->cvaddr);
3994 
3995                 /*
3996                  * release mutex associated with this cookie.
3997                  */
3998                 mutex_destroy(&cp->lock);
3999                 break;
4000         case KMEM_NON_PAGEABLE :
4001                 ASSERT(cp->cvaddr != NULL && cp->size != 0);
4002                 devmap_umem_free_np(cp->cvaddr, cp->size);
4003                 break;
4004         case UMEM_TRASH :
4005                 break;
4006         case UMEM_LOCKED :
4007                 /* Callers should use ddi_umem_unlock for this type */
4008                 ddi_umem_unlock(cookie);
4009                 /* Frees the cookie too */
4010                 return;