Re: [PATCH 1/2] block: only allocate poll_stats if there's a user of them

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

 



Hi Jens,

On Tue, Nov 23, 2021 at 12:15:18PM -0700, Jens Axboe wrote:
> +bool blk_stats_alloc_enable(struct request_queue *q)
> +{
> +	struct blk_rq_stat *poll_stat;
> +
> +	poll_stat = kcalloc(BLK_MQ_POLL_STATS_BKTS, sizeof(*poll_stat),
> +				GFP_ATOMIC);
> +	if (!poll_stat)
> +		return false;
> +
> +	if (cmpxchg(&q->poll_stat, poll_stat, NULL) != poll_stat) {
Isn't the logic inverted here? As we already check for non-NULL
q->poll_stat at the caller side, shouldn't it be:

if (cmpxchg(&q->poll_stat, NULL, poll_stat) != NULL) {

> +		kfree(poll_stat);
> +		return true;
> +	}
> +
> -- 
> 2.34.0
> 
Regards,
Pankaj



[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