target: fix a memory leak in pscsi_map_sg()
PATCH 1/1 target: fix a memory leak in pscsi_map_sg()
If blk_rq_append_bio() fails, the bio should be released before returning. This patch also removes a "bio = NULL" assignment which is not needed because the bio pointer will be immediatly reassigned after the jump.
Signed-off-by Maurizio Lombardi <[email protected]>
--- drivers/target/target_core_pscsi.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/target/target_core_pscsi.c +2 -5
@@ -948,11 +948,6 @@ static inline struct bio *pscsi_get_bio(int nr_vecs) goto fail; } -/* -* Clear the pointer so that another bio will -* be allocated with pscsi_get_bio() above. -*/ - bio =NULL ; goto new_bio; }
@@ -970,6 +965,8 @@ static inline struct bio *pscsi_get_bio(int nr_vecs)return 0 ; fail: +if (bio) +bio_put (bio);return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE ; }
Signature · 1 line
Maurizio Lombardi