> On 4/26/21 9:12 PM, Changheun Lee wrote: > > Actually I checked "bio->bi_disk" at first as below. It works well. > > Agreed that the bi_disk pointer needs to be checked. > > > I think "bi_bdev->bd_disk" checking might be needed too. > > bio_max_size() occurs in the hot path. Since if-tests have a runtime > cost I'd like to keep the number of if-tests inside bio_max_size() to a > minimum. > > I only found one bd_disk assignment in the kernel tree, namely inside > bdev_alloc(). The two bdev_alloc() calls I found inside the kernel tree > pass a valid disk pointer to bdev_alloc(). So I think it is not > necessary to check the disk pointer inside bio_max_size(). > > Thanks, > > Bart. I think bio->bi_bdev should be null in bio_copy_kern(), or bio_map_kern() logically. Because it is simple buffer mapping in driver layer. Actually bio->bi_bdev is null in my test environment. So bio->bi_bdev check only is enough as Bart's patch. Actually I don't know why NULL pointer dereference is occurred with Bart's patch in blk_rq_map_kern(). And same problem have not occured yet in my test environment with Bart's patch. Maybe I missed something, or missunderstood? Thanks, Changheun Lee.