Re: [PATCH 4/5] ISDN-Gigaset: Release memory in gigaset_initcs() after an allocation failure

From: SF Markus Elfring
Date: Tue Sep 27 2016 - 11:11:03 EST


>> @@ -772,8 +775,9 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
>>
>> gig_dbg(DEBUG_INIT, "cs initialized");
>> return cs;
>> -
>> -error:
>> +free_bcs:
>> + kfree(cs->bcs);
>> +report_failure:
>> gig_dbg(DEBUG_INIT, "failed");
>> gigaset_freecs(cs);
>
> gigaset_freecs() is not a function I look at for the fun of it. But
> still, in it we find:
>
> case 0: /* error in basic setup */
> [...]
> kfree(cs->inbuf);
> kfree(cs->bcs);
>
> As far as I can tell we will call those two kfree()'s if we jump to
> "error". So, contrary to your analysis, I don't think we leak cs->bcs.

You are right.

Thanks that you pointed this source code place out again.

I imagined that the exception handling implementation could be more direct
somehow for a while. But this function takes extra care for data synchronisation
by a mutex.

Now I recognise also that this proposed update step "4" was inappropriate.
I'm sorry for the confusion I introduced here.

Regards,
Markus