linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hfsplus: rework processing of return value of bio_alloc() in hfsplus_submit_bio()
@ 2012-11-28  9:27 Vyacheslav Dubeyko
  2012-11-28 12:48 ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Vyacheslav Dubeyko @ 2012-11-28  9:27 UTC (permalink / raw)
  To: linux-fsdevel, Andrew Morton, Christoph Hellwig, Al Viro; +Cc: Hin-Tak Leung

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 <slava@dubeyko.com>
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.

Signed-off-by: Vyacheslav Dubeyko <slava@dubeyko.com>
---
 fs/hfsplus/wrapper.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/hfsplus/wrapper.c b/fs/hfsplus/wrapper.c
index 90effcc..ec06bd4 100644
--- a/fs/hfsplus/wrapper.c
+++ b/fs/hfsplus/wrapper.c
@@ -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;
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] hfsplus: rework processing of return value of bio_alloc() in hfsplus_submit_bio()
  2012-11-28  9:27 [PATCH] hfsplus: rework processing of return value of bio_alloc() in hfsplus_submit_bio() Vyacheslav Dubeyko
@ 2012-11-28 12:48 ` Christoph Hellwig
  2012-11-28 13:18   ` Vyacheslav Dubeyko
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2012-11-28 12:48 UTC (permalink / raw)
  To: Vyacheslav Dubeyko
  Cc: linux-fsdevel, Andrew Morton, Christoph Hellwig, Al Viro,
	Hin-Tak Leung

On Wed, Nov 28, 2012 at 01:27:34PM +0400, Vyacheslav Dubeyko wrote:
> 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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hfsplus: rework processing of return value of bio_alloc() in hfsplus_submit_bio()
  2012-11-28 12:48 ` Christoph Hellwig
@ 2012-11-28 13:18   ` Vyacheslav Dubeyko
  2012-11-28 13:22     ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Vyacheslav Dubeyko @ 2012-11-28 13:18 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-fsdevel, Andrew Morton, Al Viro, Hin-Tak Leung

On Wed, 2012-11-28 at 07:48 -0500, Christoph Hellwig wrote:
> On Wed, Nov 28, 2012 at 01:27:34PM +0400, Vyacheslav Dubeyko wrote:
> > 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.

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hfsplus: rework processing of return value of bio_alloc() in hfsplus_submit_bio()
  2012-11-28 13:18   ` Vyacheslav Dubeyko
@ 2012-11-28 13:22     ` Christoph Hellwig
  2012-11-28 13:37       ` Vyacheslav Dubeyko
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2012-11-28 13:22 UTC (permalink / raw)
  To: Vyacheslav Dubeyko
  Cc: Christoph Hellwig, linux-fsdevel, Andrew Morton, Al Viro,
	Hin-Tak Leung

On Wed, Nov 28, 2012 at 05:18:19PM +0400, Vyacheslav Dubeyko wrote:
> 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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hfsplus: rework processing of return value of bio_alloc() in hfsplus_submit_bio()
  2012-11-28 13:22     ` Christoph Hellwig
@ 2012-11-28 13:37       ` Vyacheslav Dubeyko
  0 siblings, 0 replies; 5+ messages in thread
From: Vyacheslav Dubeyko @ 2012-11-28 13:37 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-fsdevel, Andrew Morton, Al Viro, Hin-Tak Leung

On Wed, 2012-11-28 at 08:22 -0500, Christoph Hellwig wrote:
> On Wed, Nov 28, 2012 at 05:18:19PM +0400, Vyacheslav Dubeyko wrote:
> > 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.
> 

Ok. Agree. Thank you. :-)

With the best regards,
Vyacheslav Dubeyko.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-11-28 13:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-28  9:27 [PATCH] hfsplus: rework processing of return value of bio_alloc() in hfsplus_submit_bio() Vyacheslav Dubeyko
2012-11-28 12:48 ` Christoph Hellwig
2012-11-28 13:18   ` Vyacheslav Dubeyko
2012-11-28 13:22     ` Christoph Hellwig
2012-11-28 13:37       ` Vyacheslav Dubeyko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).