Linux-XFS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] libfrog: fix a potential null pointer dereference
@ 2020-10-08  3:57 Darrick J. Wong
  2020-10-08 20:16 ` Eric Sandeen
  2020-10-15  8:26 ` Christoph Hellwig
  0 siblings, 2 replies; 3+ messages in thread
From: Darrick J. Wong @ 2020-10-08  3:57 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

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

Apparently, gcc 10.2 thinks that it's possible for either of the calloc
arguments to be zero here, in which case it will return NULL with a zero
errno.  I suppose it's possible to do that via integer overflow in the
macro, though I find it unlikely unless someone passes in a yuuuge value.

Nevertheless, just shut up the warning by hardcoding the error number
so I can move on to nastier bugs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libfrog/bulkstat.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libfrog/bulkstat.c b/libfrog/bulkstat.c
index c3e5c5f804e4..195f6ea053bd 100644
--- a/libfrog/bulkstat.c
+++ b/libfrog/bulkstat.c
@@ -428,7 +428,7 @@ xfrog_bulkstat_alloc_req(
 
 	breq = calloc(1, XFS_BULKSTAT_REQ_SIZE(nr));
 	if (!breq)
-		return -errno;
+		return -ENOMEM;
 
 	breq->hdr.icount = nr;
 	breq->hdr.ino = startino;

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

* Re: [PATCH] libfrog: fix a potential null pointer dereference
  2020-10-08  3:57 [PATCH] libfrog: fix a potential null pointer dereference Darrick J. Wong
@ 2020-10-08 20:16 ` Eric Sandeen
  2020-10-15  8:26 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Sandeen @ 2020-10-08 20:16 UTC (permalink / raw)
  To: Darrick J. Wong, Eric Sandeen; +Cc: xfs

On 10/7/20 10:57 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Apparently, gcc 10.2 thinks that it's possible for either of the calloc
> arguments to be zero here, in which case it will return NULL with a zero
> errno.  I suppose it's possible to do that via integer overflow in the
> macro, though I find it unlikely unless someone passes in a yuuuge value.
> 
> Nevertheless, just shut up the warning by hardcoding the error number
> so I can move on to nastier bugs.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  libfrog/bulkstat.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libfrog/bulkstat.c b/libfrog/bulkstat.c
> index c3e5c5f804e4..195f6ea053bd 100644
> --- a/libfrog/bulkstat.c
> +++ b/libfrog/bulkstat.c
> @@ -428,7 +428,7 @@ xfrog_bulkstat_alloc_req(
>  
>  	breq = calloc(1, XFS_BULKSTAT_REQ_SIZE(nr));
>  	if (!breq)
> -		return -errno;
> +		return -ENOMEM;

Sure, why not!

Reviewed-by: Eric Sandeen <sandeen@redhat.com>
 
>  	breq->hdr.icount = nr;
>  	breq->hdr.ino = startino;
> 

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

* Re: [PATCH] libfrog: fix a potential null pointer dereference
  2020-10-08  3:57 [PATCH] libfrog: fix a potential null pointer dereference Darrick J. Wong
  2020-10-08 20:16 ` Eric Sandeen
@ 2020-10-15  8:26 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2020-10-15  8:26 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Eric Sandeen, xfs

Looks good,

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

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-08  3:57 [PATCH] libfrog: fix a potential null pointer dereference Darrick J. Wong
2020-10-08 20:16 ` Eric Sandeen
2020-10-15  8:26 ` Christoph Hellwig

Linux-XFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-xfs/0 linux-xfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-xfs linux-xfs/ https://lore.kernel.org/linux-xfs \
		linux-xfs@vger.kernel.org
	public-inbox-index linux-xfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-xfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git