Message ID | 20221105095357.21199-1-yekai13@huawei.com |
---|---|
Headers | show |
Series | crypto: hisilicon/qm - reconstruct and optimize the debugfs code | expand |
On Sat, Nov 05, 2022 at 09:53:54AM +0000, Kai Ye wrote: > > +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; > +} The line that I complained about is still here. Cheers,
On 2022/11/5 18:18, Herbert Xu wrote: > On Sat, Nov 05, 2022 at 09:53:54AM +0000, Kai Ye wrote: >> +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; >> +} > The line that I complained about is still here. > > Cheers, ok thanks kai
On Mon, Nov 07, 2022 at 02:53:28PM +0800, yekai (A) wrote: > > > On 2022/11/5 18:18, Herbert Xu wrote: > > On Sat, Nov 05, 2022 at 09:53:54AM +0000, Kai Ye wrote: > >> +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; > >> +} > > The line that I complained about is still here. > > > > Cheers, > > ok Just to be clear, it's the last line "dregs = NULL" that I was referring to. It makes no sense to zero a variable that is on the stack. Cheers,
On 2022/11/7 16:47, Herbert Xu wrote: > On Mon, Nov 07, 2022 at 02:53:28PM +0800, yekai (A) wrote: >> >> On 2022/11/5 18:18, Herbert Xu wrote: >>> On Sat, Nov 05, 2022 at 09:53:54AM +0000, Kai Ye wrote: >>>> +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; >>>> +} >>> The line that I complained about is still here. >>> >>> Cheers, >> ok > Just to be clear, it's the last line "dregs = NULL" that I was > referring to. It makes no sense to zero a variable that is on > the stack. > > Cheers, I got it. I will fix it and resend the patch set in the next version. Thanks Kai