All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: xfs_dabuf_map should return ENOMEM when map allocation fails
@ 2020-03-14 17:29 Darrick J. Wong
  2020-03-14 18:18 ` Christoph Hellwig
  2020-03-15  6:04 ` Chaitanya Kulkarni
  0 siblings, 2 replies; 3+ messages in thread
From: Darrick J. Wong @ 2020-03-14 17:29 UTC (permalink / raw)
  To: xfs; +Cc: Christoph Hellwig

From: Darrick J. Wong <darrick.wong@oracle.com>

If the xfs_buf_map array allocation in xfs_dabuf_map fails for whatever
reason, we bail out with error code zero.  This will confuse callers, so
make sure that we return ENOMEM.  Allocation failure should never happen
with the small size of the array, but code defensively anyway.

Fixes: 45feef8f50b94d ("xfs: refactor xfs_dabuf_map")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_da_btree.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index a7880c6285db..897749c41f36 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -2521,8 +2521,10 @@ xfs_dabuf_map(
 	 */
 	if (nirecs > 1) {
 		map = kmem_zalloc(nirecs * sizeof(struct xfs_buf_map), KM_NOFS);
-		if (!map)
+		if (!map) {
+			error = -ENOMEM;
 			goto out_free_irecs;
+		}
 		*mapp = map;
 	}
 

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

* Re: [PATCH] xfs: xfs_dabuf_map should return ENOMEM when map allocation fails
  2020-03-14 17:29 [PATCH] xfs: xfs_dabuf_map should return ENOMEM when map allocation fails Darrick J. Wong
@ 2020-03-14 18:18 ` Christoph Hellwig
  2020-03-15  6:04 ` Chaitanya Kulkarni
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2020-03-14 18:18 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: xfs, Christoph Hellwig

On Sat, Mar 14, 2020 at 10:29:13AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> If the xfs_buf_map array allocation in xfs_dabuf_map fails for whatever
> reason, we bail out with error code zero.  This will confuse callers, so
> make sure that we return ENOMEM.  Allocation failure should never happen
> with the small size of the array, but code defensively anyway.
> 
> Fixes: 45feef8f50b94d ("xfs: refactor xfs_dabuf_map")
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH] xfs: xfs_dabuf_map should return ENOMEM when map allocation fails
  2020-03-14 17:29 [PATCH] xfs: xfs_dabuf_map should return ENOMEM when map allocation fails Darrick J. Wong
  2020-03-14 18:18 ` Christoph Hellwig
@ 2020-03-15  6:04 ` Chaitanya Kulkarni
  1 sibling, 0 replies; 3+ messages in thread
From: Chaitanya Kulkarni @ 2020-03-15  6:04 UTC (permalink / raw)
  To: Darrick J. Wong, xfs; +Cc: Christoph Hellwig

I've verified the commit "45feef8f50b94d56d6a433ad5baf5cdf58e3db98",
which was adds goto statement and it make sense to set error to
-ENOMEM when kmem_zalloc() fails.

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

On 03/14/2020 06:44 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong<darrick.wong@oracle.com>
>
> If the xfs_buf_map array allocation in xfs_dabuf_map fails for whatever
> reason, we bail out with error code zero.  This will confuse callers, so
> make sure that we return ENOMEM.  Allocation failure should never happen
> with the small size of the array, but code defensively anyway.
>
> Fixes: 45feef8f50b94d ("xfs: refactor xfs_dabuf_map")
> Signed-off-by: Darrick J. Wong<darrick.wong@oracle.com>
> ---


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

end of thread, other threads:[~2020-03-15  7:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-14 17:29 [PATCH] xfs: xfs_dabuf_map should return ENOMEM when map allocation fails Darrick J. Wong
2020-03-14 18:18 ` Christoph Hellwig
2020-03-15  6:04 ` Chaitanya Kulkarni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.