Re: [PATCH] Cleanups for: line length, printk KERN_ argument, stack frame size > 2048 (added a kmalloc/kfree), style/formatting errors, incorrect include files

From: Bruce B
Date: Fri Oct 09 2009 - 17:33:09 EST





On Oct 9, 2009, at 2:16 PM, Greg KH wrote:


Try changing one thing at a time per patch please.

There's some bugs in here:

- struct config_t dig_in_config[32];
- struct config_t dig_out_config[32];
- struct config_t chan_in_config[32];
- struct config_t chan_out_config[32];
int i;
+ config_data = kmalloc(sizeof(struct config_data_t), GFP_KERNEL);

Shouldn't that be:
config_data = kmalloc(sizeof(struct config_data_t)*32, GFP_KERNEL);


The structure already has the [32]'s copied from the original defn's.
If you like... I can still break up the commit into two patches. Also, moving the *32 out isn't a bad idea; were I
to break it up, I would likely do so.



Otherwise you overflow your buffer here:

for (i = 0; i < 32; i++) {
- dig_in_config[i].kind = 0;
- dig_in_config[i].bits = 0;
- dig_in_config[i].min = 0;
- dig_in_config[i].max = 0;
- dig_out_config[i].kind = 0;
- dig_out_config[i].bits = 0;
- dig_out_config[i].min = 0;
- dig_out_config[i].max = 0;
- chan_in_config[i].kind = 0;
- chan_in_config[i].bits = 0;
- chan_in_config[i].min = 0;
- chan_in_config[i].max = 0;
- chan_out_config[i].kind = 0;
- chan_out_config[i].bits = 0;
- chan_out_config[i].min = 0;
- chan_out_config[i].max = 0;
+ config_data->dig_in_config[i].kind = 0;
+ config_data->dig_in_config[i].bits = 0;
+ config_data->dig_in_config[i].min = 0;
+ config_data->dig_in_config[i].max = 0;
+ config_data->dig_out_config[i].kind = 0;
+ config_data->dig_out_config[i].bits = 0;
+ config_data->dig_out_config[i].min = 0;
+ config_data->dig_out_config[i].max = 0;
+ config_data->chan_in_config[i].kind = 0;
+ config_data->chan_in_config[i].bits = 0;
+ config_data->chan_in_config[i].min = 0;
+ config_data->chan_in_config[i].max = 0;
+ config_data->chan_out_config[i].kind = 0;
+ config_data->chan_out_config[i].bits = 0;
+ config_data->chan_out_config[i].min = 0;
+ config_data->chan_out_config[i].max = 0;
}

Or am I mistaken?

thanks,

greg k-h

--
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/