Print this page
5253 kmem_alloc/kmem_zalloc won't fail with KM_SLEEP
5254 getrbuf won't fail with KM_SLEEP


 112                 return (PCIEHPC_PROP_VALUE_UNUSABLE);
 113         default:
 114                 return (PCIEHPC_PROP_VALUE_UNKNOWN);
 115         }
 116 }
 117 
 118 /*
 119  * routine to copy in a nvlist from userland
 120  */
 121 int
 122 pcie_copyin_nvlist(char *packed_buf, size_t packed_sz, nvlist_t **nvlp)
 123 {
 124         int             ret = DDI_SUCCESS;
 125         char            *packed;
 126         nvlist_t        *dest = NULL;
 127 
 128         if (packed_buf == NULL || packed_sz == 0)
 129                 return (DDI_EINVAL);
 130 
 131         /* copyin packed nvlist */
 132         if ((packed = kmem_alloc(packed_sz, KM_SLEEP)) == NULL)
 133                 return (DDI_ENOMEM);
 134 
 135         if (copyin(packed_buf, packed, packed_sz) != 0) {
 136                 cmn_err(CE_WARN, "pcie_copyin_nvlist: copyin failed.\n");
 137                 ret = DDI_FAILURE;
 138                 goto copyin_cleanup;
 139         }
 140 
 141         /* unpack packed nvlist */
 142         if ((ret = nvlist_unpack(packed, packed_sz, &dest, KM_SLEEP)) != 0) {
 143                 cmn_err(CE_WARN, "pcie_copyin_nvlist: nvlist_unpack "
 144                     "failed with err %d\n", ret);
 145                 switch (ret) {
 146                 case EINVAL:
 147                 case ENOTSUP:
 148                         ret = DDI_EINVAL;
 149                         goto copyin_cleanup;
 150                 case ENOMEM:
 151                         ret = DDI_ENOMEM;
 152                         goto copyin_cleanup;
 153                 default:




 112                 return (PCIEHPC_PROP_VALUE_UNUSABLE);
 113         default:
 114                 return (PCIEHPC_PROP_VALUE_UNKNOWN);
 115         }
 116 }
 117 
 118 /*
 119  * routine to copy in a nvlist from userland
 120  */
 121 int
 122 pcie_copyin_nvlist(char *packed_buf, size_t packed_sz, nvlist_t **nvlp)
 123 {
 124         int             ret = DDI_SUCCESS;
 125         char            *packed;
 126         nvlist_t        *dest = NULL;
 127 
 128         if (packed_buf == NULL || packed_sz == 0)
 129                 return (DDI_EINVAL);
 130 
 131         /* copyin packed nvlist */
 132         packed = kmem_alloc(packed_sz, KM_SLEEP);

 133 
 134         if (copyin(packed_buf, packed, packed_sz) != 0) {
 135                 cmn_err(CE_WARN, "pcie_copyin_nvlist: copyin failed.\n");
 136                 ret = DDI_FAILURE;
 137                 goto copyin_cleanup;
 138         }
 139 
 140         /* unpack packed nvlist */
 141         if ((ret = nvlist_unpack(packed, packed_sz, &dest, KM_SLEEP)) != 0) {
 142                 cmn_err(CE_WARN, "pcie_copyin_nvlist: nvlist_unpack "
 143                     "failed with err %d\n", ret);
 144                 switch (ret) {
 145                 case EINVAL:
 146                 case ENOTSUP:
 147                         ret = DDI_EINVAL;
 148                         goto copyin_cleanup;
 149                 case ENOMEM:
 150                         ret = DDI_ENOMEM;
 151                         goto copyin_cleanup;
 152                 default: