[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <99ab354d-b6b4-40e0-9f7a-d83b195e5719@suse.de>
Date: Fri, 4 Oct 2024 16:15:25 +0200
From: Hannes Reinecke <hare@...e.de>
To: SurajSonawane2415 <surajsonawane0215@...il.com>, hch@...radead.org
Cc: axboe@...nel.dk, linux-block@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: Explanation on Uninitialized Variable bio in blk_rq_prep_clone
On 10/4/24 16:10, SurajSonawane2415 wrote:
> Explaination of how bio could be used uninitialized in this function:
>
> In the function blk_rq_prep_clone, the variable bio is declared but can remain uninitialized
> if the allocation with bio_alloc_clone fails. This can lead to undefined behavior when the
> function attempts to free bio in the error handling section using bio_put(bio).
> By initializing bio to NULL at declaration, we ensure that the cleanup code will only
> interact with bio if it has been successfully allocated.
>
Hate to say it, but it looks you are correct.
Care to send a patch?
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@...e.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Powered by blists - more mailing lists