Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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



Signed-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
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -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;