Re: [PULL}: latest tip/cpus4096 changes

From: Mike Travis
Date: Fri Jan 16 2009 - 12:54:45 EST


Ingo Molnar wrote:
> * Mike Travis <travis@xxxxxxx> wrote:
>
>> diff --git a/kernel/kgdb.c b/kernel/kgdb.c
>> index e4dcfb2..21fde60 100644
>> --- a/kernel/kgdb.c
>> +++ b/kernel/kgdb.c
>> @@ -72,7 +72,7 @@ struct kgdb_state {
>> static struct debuggerinfo_struct {
>> void *debuggerinfo;
>> struct task_struct *task;
>> -} kgdb_info[NR_CPUS];
>> +} *kgdb_info;
>>
>> /**
>> * kgdb_connected - Is a host GDB connected to us?
>> @@ -1651,6 +1651,13 @@ int kgdb_register_io_module(struct kgdb_io *new_kgdb_io_ops)
>> return -EBUSY;
>> }
>>
>> + kgdb_info = kmalloc(nr_cpu_ids * sizeof(*kgdb_info), GFP_KERNEL);
>> + if (unlikely(!kgdb_info)) {
>> + spin_unlock(&kgdb_registration_lock);
>> + printk(KERN_ERR "kgdb: No memory for kgdb_info\n");
>> + return -ENOMEM;
>> + }
>> +
>> if (new_kgdb_io_ops->init) {
>> err = new_kgdb_io_ops->init();
>> if (err) {
>
> Look how it continues:
>
> spin_unlock(&kgdb_registration_lock);
> return err;
> }
> }
>
> See the memory leak? This is _trivially_ broken. When you add dynamic
> allocation to any codepath you _need_ to be careul and you need to check
> all interim paths of return.
>
> Also, please submit kgdb patches via the KGDB maintainer:
>
> KGDB
> P: Jason Wessel
> M: jason.wessel@xxxxxxxxxxxxx
> L: kgdb-bugreport@xxxxxxxxxxxxxxxxxxxxx
> S: Maintained
>
> Ingo

Yes, you're right I did miss that. And I'll send it to Jason.

Thanks,
MIke

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/