Re: [PATCH v2 4/5] blk-iocost: fix sleeping in atomic context warnning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, Tejun

在 2022/11/23 18:22, Yu Kuai 写道:
Hi, Tejun

在 2022/11/23 8:42, Tejun Heo 写道:
On Tue, Nov 22, 2022 at 05:14:29PM -0700, Jens Axboe wrote:
Then match_strdup() and kfree() in match_NUMBER() can be replaced with
get_buffer() and put_buffer().

Sorry about the late reply. Yeah, something like this.


I wonder can we just use arary directly in stack? The max size is just
24 bytes, which should be fine:

HEX: "0xFFFFFFFFFFFFFFFF" --> 18
DEC: "18446744073709551615" --> 20
OCT: "01777777777777777777777" --> 23

Something like:
#define U64_MAX_SIZE 23
static int match_strdup_local(const substring_t *s, char *buf)
{
	size_t len = s->to - s->from;

	if (len > U64_MAX_SIZE)
		return -ERANGE;

	if (!s->from)
		return -EINVAL;

	memcpy(buf, s->from, len);
	buf[len] = '\0';
	return 0;
}

 static int match_u64int(substring_t *s, u64 *result, int base)
 {
	char buf[U64_MAX_SIZE + 1];
 	int ret;
 	u64 val;

	ret = match_strdup_local(s, buf);
	if (ret)
		return ret;
 	ret = kstrtoull(buf, base, &val);
 	if (!ret)
 		*result = val;;
 	return ret;
 }




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux