Commit 839fafbe authored by Thomas Meyer's avatar Thomas Meyer Committed by John W. Linville

rt2x00: Use kcalloc instead of kzalloc to allocate array

The advantage of kcalloc is, that will prevent integer overflows which could
result from the multiplication of number of elements and size and it is also
a bit nicer to read.

The semantic patch that makes this change is available
in https://lkml.org/lkml/2011/11/25/107Signed-off-by: default avatarThomas Meyer <thomas@m3y3r.de>
Acked-by: default avatarGertjan van Wingerde <gwingerde@gmail.com>
Acked-by: default avatarIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 5f779bbd
...@@ -831,11 +831,11 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev, ...@@ -831,11 +831,11 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
if (spec->supported_rates & SUPPORT_RATE_OFDM) if (spec->supported_rates & SUPPORT_RATE_OFDM)
num_rates += 8; num_rates += 8;
channels = kzalloc(sizeof(*channels) * spec->num_channels, GFP_KERNEL); channels = kcalloc(spec->num_channels, sizeof(*channels), GFP_KERNEL);
if (!channels) if (!channels)
return -ENOMEM; return -ENOMEM;
rates = kzalloc(sizeof(*rates) * num_rates, GFP_KERNEL); rates = kcalloc(num_rates, sizeof(*rates), GFP_KERNEL);
if (!rates) if (!rates)
goto exit_free_channels; goto exit_free_channels;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment