[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <851c1b30-ee30-145b-c77c-17166cd6e426@huawei.com>
Date: Fri, 4 Nov 2022 18:07:05 +0800
From: "yekai (A)" <yekai13@...wei.com>
To: Herbert Xu <herbert@...dor.apana.org.au>
CC: <linux-crypto@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/3] crypto: hisilicon/qm - modify the process of regs dfx
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
Powered by blists - more mailing lists