Re: [PATCH 1/3] crypto: hisilicon/qm - modify the process of regs dfx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 2022/11/4 17:05, Herbert Xu wrote:
> On Sat, Oct 29, 2022 at 09:47:59AM +0000, Kai Ye wrote:
>> diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c
>> index 363a02810a16..832cfd9a7728 100644
>> --- a/drivers/crypto/hisilicon/qm.c
>> +++ b/drivers/crypto/hisilicon/qm.c
>> @@ -1722,8 +1722,22 @@ static int qm_regs_show(struct seq_file *s, void *unused)
>>  
>>  DEFINE_SHOW_ATTRIBUTE(qm_regs);
>>  
>> +static void dfx_regs_uninit(struct hisi_qm *qm,
>> +		struct dfx_diff_registers *dregs, int reg_len)
>> +{
>> +	int i;
>> +
>> +	/* Setting the pointer is NULL to prevent double free */
>> +	for (i = 0; i < reg_len; i++) {
>> +		kfree(dregs[i].regs);
>> +		dregs[i].regs = NULL;
>> +	}
>> +	kfree(dregs);
>> +	dregs = NULL;
> What's the point of this last NULL assignment?
>
> Cheers,

To prevent pointer reuse and reduce register data security risks. So the original code setting the pointer is NULL.
 
Thanks
Kai



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux