Commit c2e4e3b7 authored by Gustavo A. R. Silva's avatar Gustavo A. R. Silva
Browse files

xfs: Use kvcalloc() instead of kvzalloc()

Use 2-factor argument multiplication form kvcalloc() instead of
kvzalloc().

Link: https://github.com/KSPP/linux/issues/162


Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
parent 2a12e000
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -1547,7 +1547,7 @@ xfs_ioc_getbmap(
	if (bmx.bmv_count > ULONG_MAX / recsize)
	if (bmx.bmv_count > ULONG_MAX / recsize)
		return -ENOMEM;
		return -ENOMEM;


	buf = kvzalloc(bmx.bmv_count * sizeof(*buf), GFP_KERNEL);
	buf = kvcalloc(bmx.bmv_count, sizeof(*buf), GFP_KERNEL);
	if (!buf)
	if (!buf)
		return -ENOMEM;
		return -ENOMEM;


@@ -1601,11 +1601,11 @@ xfs_ioc_getfsmap(
	 */
	 */
	count = min_t(unsigned int, head.fmh_count,
	count = min_t(unsigned int, head.fmh_count,
			131072 / sizeof(struct fsmap));
			131072 / sizeof(struct fsmap));
	recs = kvzalloc(count * sizeof(struct fsmap), GFP_KERNEL);
	recs = kvcalloc(count, sizeof(struct fsmap), GFP_KERNEL);
	if (!recs) {
	if (!recs) {
		count = min_t(unsigned int, head.fmh_count,
		count = min_t(unsigned int, head.fmh_count,
				PAGE_SIZE / sizeof(struct fsmap));
				PAGE_SIZE / sizeof(struct fsmap));
		recs = kvzalloc(count * sizeof(struct fsmap), GFP_KERNEL);
		recs = kvcalloc(count, sizeof(struct fsmap), GFP_KERNEL);
		if (!recs)
		if (!recs)
			return -ENOMEM;
			return -ENOMEM;
	}
	}