Re: [PATCH v4 3/7] blk-mq: Fix use after of free q->mq_map

From: Akinobu Mita
Date: Mon Oct 05 2015 - 19:50:52 EST


2015-09-29 15:52 GMT+09:00 Christoph Hellwig <hch@xxxxxx>:
> Looks good,
>
> Reviewed-by: Christoph Hellwig <hch@xxxxxx>
>
> Can you also add a patch that renames blk_mq_free_queue to
> blk_mq_cleaup_queue and adds a comment that we should not free any memory
> here? We had way too many bugs of this kinds unfortunately.

Renaming blk_mq_free_queue to blk_mq_cleaup_queue sounds good because
it is called from blk_cleanup_queue().

How about adding comment like below?

/*
* The resources allocated by blk_mq_init_allocated_queue() are released
* by blk_mq_cleanup_queue() and blk_mq_release().
*
* blk_mq_cleanup_queue() is called from blk_cleanup_queue(), so
* the resources which may be used after blk_cleanup_queue() shouldn't
* be released here. Instead, those should be released by blk_mq_release()
* which is called from blk_release_queue().
*
* For example, loop and md drivers call del_gendisk() after
* blk_cleanup_queue(), so the resources used when accessing sysfs entries
* for blk-mq shouldn't be released by blk_mq_cleanup_queue() as these sysfs
* entries can be accessible before del_gendisk() is called.
*/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/