@@ -1341,14 +1341,13 @@ SMB2_sess_alloc_buffer(struct SMB2_sess_data *sess_data)
1341
1341
static void
1342
1342
SMB2_sess_free_buffer (struct SMB2_sess_data * sess_data )
1343
1343
{
1344
- int i ;
1344
+ struct kvec * iov = sess_data -> iov ;
1345
1345
1346
- /* zero the session data before freeing, as it might contain sensitive info (keys, etc) */
1347
- for (i = 0 ; i < 2 ; i ++ )
1348
- if (sess_data -> iov [i ].iov_base )
1349
- memzero_explicit (sess_data -> iov [i ].iov_base , sess_data -> iov [i ].iov_len );
1346
+ /* iov[1] is already freed by caller */
1347
+ if (sess_data -> buf0_type != CIFS_NO_BUFFER && iov [0 ].iov_base )
1348
+ memzero_explicit (iov [0 ].iov_base , iov [0 ].iov_len );
1350
1349
1351
- free_rsp_buf (sess_data -> buf0_type , sess_data -> iov [0 ].iov_base );
1350
+ free_rsp_buf (sess_data -> buf0_type , iov [0 ].iov_base );
1352
1351
sess_data -> buf0_type = CIFS_NO_BUFFER ;
1353
1352
}
1354
1353
@@ -1578,7 +1577,7 @@ SMB2_sess_auth_rawntlmssp_negotiate(struct SMB2_sess_data *sess_data)
1578
1577
}
1579
1578
1580
1579
out :
1581
- memzero_explicit (ntlmssp_blob , blob_length );
1580
+ kfree_sensitive (ntlmssp_blob );
1582
1581
SMB2_sess_free_buffer (sess_data );
1583
1582
if (!rc ) {
1584
1583
sess_data -> result = 0 ;
@@ -1662,7 +1661,7 @@ SMB2_sess_auth_rawntlmssp_authenticate(struct SMB2_sess_data *sess_data)
1662
1661
}
1663
1662
#endif
1664
1663
out :
1665
- memzero_explicit (ntlmssp_blob , blob_length );
1664
+ kfree_sensitive (ntlmssp_blob );
1666
1665
SMB2_sess_free_buffer (sess_data );
1667
1666
kfree_sensitive (ses -> ntlmssp );
1668
1667
ses -> ntlmssp = NULL ;
0 commit comments