Skip to contentSkip to conversation

hfsplus: rework processing of return value of bio_alloc() in hfsplus_submit_bio()

PATCH In review Vyacheslav Dubeyko 2 participants 5 messages Nov 28, 2012

Subsystems (2)
lore
Share & tools
lore

Vyacheslav Dubeyko

author maintainer
#0 lore raw

PATCH 1/1 hfsplus: rework processing of return value of bio_alloc() in hfsplus_submit_bio()

Hi,

This patch adds logic of checking return value of bio_alloc() in hfsplus_submit_bio(). In the case of NULL the hfsplus_submit_bio() returns -EIO.

With the best regards,
Vyacheslav Dubeyko.
--
From: Vyacheslav Dubeyko <[email protected]>
Subject: [PATCH] hfsplus: rework processing of return value of bio_alloc() in hfsplus_submit_bio()

This patch adds logic of checking return value of bio_alloc() in hfsplus_submit_bio(). In the case of NULL the hfsplus_submit_bio() returns -EIO.

---
 fs/hfsplus/wrapper.c |    3 +++
 1 file changed, 3 insertions(+)
fs/hfsplus/wrapper.c +3 -0
index 90effcc..ec06bd4 100644
@@ -71,6 +71,9 @@ int hfsplus_submit_bio(struct super_block *sb, sector_t sector,
 	sector &= ~((io_size >> HFSPLUS_SECTOR_SHIFT) - 1);
 
 	bio = bio_alloc(GFP_NOIO, 1);
+	if (!bio)
+		return -EIO;
+
 	bio->bi_sector = sector;
 	bio->bi_bdev = sb->s_bdev;
 	bio->bi_end_io = hfsplus_end_io_sync;
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 3 lines · Vyacheslav Dubeyko

Hi,

This patch adds logic of checking return value of bio_alloc() in hfsplus_submit_bio(). In the case of NULL the hfsplus_submit_bio() returns -EIO.

bio_alloc does a mempool allocation and thus will never return NULL.

author maintainer
#2 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Vyacheslav Dubeyko

Hi,

This patch adds logic of checking return value of bio_alloc() in hfsplus_submit_bio(). In the case of NULL the hfsplus_submit_bio() returns -EIO.

bio_alloc does a mempool allocation and thus will never return NULL.

I don't insist on the patch. But if the function has such description:

* RETURNS:
* Pointer to new bio on success, NULL on failure.

I prefer to check on NULL anyway. :-)

With the best regards,
Vyacheslav Dubeyko.

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 6 lines · Vyacheslav Dubeyko

I don't insist on the patch. But if the function has such description:

* RETURNS:
* Pointer to new bio on success, NULL on failure.

I prefer to check on NULL anyway. :-)

Check the sentence a couple lines above in the same comment:

* When @bs is not NULL, if %__GFP_WAIT is set then bio_alloc will always be
* able to allocate a bio. This is due to the mempool guarantees.

author maintainer
#4 lore raw
Quoted 6 lines · Christoph Hellwig
Quoted 5 lines · Vyacheslav Dubeyko

I don't insist on the patch. But if the function has such description:

* RETURNS:
* Pointer to new bio on success, NULL on failure.

Quoted 8 lines
Quoted 1 line

I prefer to check on NULL anyway. :-)

Check the sentence a couple lines above in the same comment:

* When @bs is not NULL, if %__GFP_WAIT is set then bio_alloc will always be
* able to allocate a bio. This is due to the mempool guarantees.

Ok. Agree. Thank you. :-)

With the best regards,
Vyacheslav Dubeyko.