Re: [PATCH] md: md2: fix an incorrect NULL check on list iterator

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

 



> I'd suggest to rephrase the subject to "md: fix an incorrect NULL check 
> in md_reload_sb".

Thank you for the suggestion, i will take it in PATCH v2.

> > -	if (!rdev || rdev->desc_nr != nr) {
> > +	if (!rdev) {
> >   		pr_warn("%s: %d Could not find rdev with nr %d\n", __func__, __LINE__, nr);
> >   		return;
> >   	}
> 
> I guess we only need to check desc_nr since rdev should always be valid 
> , and IMO the fix tag
> is not necessary.

No. At least from the pr_warn log, the list can be empty or no element found in it.
If this cases happen, the 'rdev' will be an invalid pointer that point to a invalid
struct containning the HEAD '&((mddev)->disks)'. So this fix is necessary.

--
Xiaomeng Tong



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux