Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: nx - Fix uninitialised hv_nxc on error

The compiler correctly warns that hv_nxc may be used uninitialised
as that will occur when NX-GZIP is unavailable.

Fix it by rearranging the code and delay setting caps_feat until
the final query succeeds.

Fixes: b4ba22114c78 ("crypto/nx: Get NX capabilities for GZIP coprocessor type")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+17 -20
+17 -20
drivers/crypto/nx/nx-common-pseries.c
··· 1145 1145 { 1146 1146 struct hv_vas_all_caps *hv_caps; 1147 1147 struct hv_nx_cop_caps *hv_nxc; 1148 + u64 feat; 1148 1149 int rc; 1149 1150 1150 1151 hv_caps = kmalloc(sizeof(*hv_caps), GFP_KERNEL); ··· 1156 1155 */ 1157 1156 rc = h_query_vas_capabilities(H_QUERY_NX_CAPABILITIES, 0, 1158 1157 (u64)virt_to_phys(hv_caps)); 1158 + if (!rc) 1159 + feat = be64_to_cpu(hv_caps->feat_type); 1160 + kfree(hv_caps); 1159 1161 if (rc) 1160 - goto out; 1162 + return; 1163 + if (!(feat & VAS_NX_GZIP_FEAT_BIT)) 1164 + return; 1161 1165 1162 - caps_feat = be64_to_cpu(hv_caps->feat_type); 1163 1166 /* 1164 1167 * NX-GZIP feature available 1165 1168 */ 1166 - if (caps_feat & VAS_NX_GZIP_FEAT_BIT) { 1167 - hv_nxc = kmalloc(sizeof(*hv_nxc), GFP_KERNEL); 1168 - if (!hv_nxc) 1169 - goto out; 1170 - /* 1171 - * Get capabilities for NX-GZIP feature 1172 - */ 1173 - rc = h_query_vas_capabilities(H_QUERY_NX_CAPABILITIES, 1174 - VAS_NX_GZIP_FEAT, 1175 - (u64)virt_to_phys(hv_nxc)); 1176 - } else { 1177 - pr_err("NX-GZIP feature is not available\n"); 1178 - rc = -EINVAL; 1179 - } 1169 + hv_nxc = kmalloc(sizeof(*hv_nxc), GFP_KERNEL); 1170 + if (!hv_nxc) 1171 + return; 1172 + /* 1173 + * Get capabilities for NX-GZIP feature 1174 + */ 1175 + rc = h_query_vas_capabilities(H_QUERY_NX_CAPABILITIES, 1176 + VAS_NX_GZIP_FEAT, 1177 + (u64)virt_to_phys(hv_nxc)); 1180 1178 1181 1179 if (!rc) { 1182 1180 nx_cop_caps.descriptor = be64_to_cpu(hv_nxc->descriptor); ··· 1185 1185 be64_to_cpu(hv_nxc->min_compress_len); 1186 1186 nx_cop_caps.min_decompress_len = 1187 1187 be64_to_cpu(hv_nxc->min_decompress_len); 1188 - } else { 1189 - caps_feat = 0; 1188 + caps_feat = feat; 1190 1189 } 1191 1190 1192 1191 kfree(hv_nxc); 1193 - out: 1194 - kfree(hv_caps); 1195 1192 } 1196 1193 1197 1194 static const struct vio_device_id nx842_vio_driver_ids[] = {