public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Luis Henriques <lhenriques@suse•com>
To: Aditya Pakki <pakki001@umn•edu>
Cc: kjlu@umn•edu, Ilya Dryomov <idryomov@gmail•com>, "Yan\,
	Zheng" <zyan@redhat•com>, Sage Weil <sage@redhat•com>,
	"David S. Miller" <davem@davemloft•net>,
	ceph-devel@vger•kernel.org, netdev@vger•kernel.org,
	linux-kernel@vger•kernel.org
Subject: Re: [PATCH] libceph: Avoid a NULL pointer dereference
Date: Fri, 15 Mar 2019 11:24:26 +0000	[thread overview]
Message-ID: <87ef78bct1.fsf@suse.com> (raw)
In-Reply-To: <20190314211724.21306-1-pakki001@umn.edu> (Aditya Pakki's message of "Thu, 14 Mar 2019 16:17:24 -0500")

Aditya Pakki <pakki001@umn•edu> writes:

> kmalloc allocates memory for dest->name and attempts to call
> memcpy without a check for failure. This patch avoids such a scenario.

Since kmalloc is being invoked with the __GFP_NOFAIL flag, it will never
fail.  Thus, there's no point in checking for NULL in this case.

Cheers,
-- 
Luis


>
> Signed-off-by: Aditya Pakki <pakki001@umn•edu>
> ---
>  net/ceph/osdmap.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
> index 48a31dc9161c..c76a7c7e6a77 100644
> --- a/net/ceph/osdmap.c
> +++ b/net/ceph/osdmap.c
> @@ -1901,6 +1901,8 @@ void ceph_oid_copy(struct ceph_object_id *dest,
>  	} else {
>  		dest->name = dest->inline_name;
>  	}
> +	if (!dest->name)
> +		return;
>  	memcpy(dest->name, src->name, src->name_len + 1);
>  	dest->name_len = src->name_len;
>  }

      reply	other threads:[~2019-03-15 11:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14 21:17 [PATCH] libceph: Avoid a NULL pointer dereference Aditya Pakki
2019-03-15 11:24 ` Luis Henriques [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ef78bct1.fsf@suse.com \
    --to=lhenriques@suse$(echo .)com \
    --cc=ceph-devel@vger$(echo .)kernel.org \
    --cc=davem@davemloft$(echo .)net \
    --cc=idryomov@gmail$(echo .)com \
    --cc=kjlu@umn$(echo .)edu \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pakki001@umn$(echo .)edu \
    --cc=sage@redhat$(echo .)com \
    --cc=zyan@redhat$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox