Re: [PATCH] block: fix lbmd_guard_tag_type assignment in FS_IOC_GETLBMD_CAP

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

 



On Tue, Jul 22, 2025 at 01:45:53AM -0700, Christoph Hellwig wrote:
> On Tue, Jul 22, 2025 at 01:49:11PM +0530, Anuj Gupta wrote:
> > +	switch (bi->csum_type) {
> > +	case BLK_INTEGRITY_CSUM_NONE:
> > +		meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_NONE;
> > +		break;
> > +	case BLK_INTEGRITY_CSUM_IP:
> > +		meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_IP;
> > +		break;
> > +	case BLK_INTEGRITY_CSUM_CRC:
> > +		meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_CRC16_T10DIF;
> > +		break;
> > +	case BLK_INTEGRITY_CSUM_CRC64:
> > +		meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_CRC64_NVME;
> > +		break;
> > +	default:
> > +		break;
> 
> This should catch and reject invalid values.  Otherwise the patch looks
> fine.

I guess reject is wrong, as the kernel is the source, but I think
a bit of validation here still makes sense.  I think if you just leave
the default out, the compiler would complain if we added a new value
to the union without handling it here, which should be enough.





[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