linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Prasanth K S R <kosigiprasanth@gmail.com>
Cc: linux-btrfs@vger.kernel.org,
	Prasanth K S R <prasanth.ksr@dell.com>,
	dsterba@suse.com
Subject: Re: [PATCH] Btrfs-progs: subvol_uuid_search: Return error code on memory allocation failure
Date: Thu, 6 Oct 2016 17:45:01 +0200	[thread overview]
Message-ID: <20161006154501.GJ6576@twin.jikos.cz> (raw)
In-Reply-To: <1475672592-3963-1-git-send-email-kosigiprasanth@gmail.com>

On Wed, Oct 05, 2016 at 06:33:12PM +0530, Prasanth K S R wrote:
> From: Prasanth K S R <prasanth.ksr@dell.com>
> 
> This commit fixes coverity defect CID 1328695.
> 
> Signed-off-by: Prasanth K S R <prasanth.ksr@dell.com>
> ---
>  send-utils.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/send-utils.c b/send-utils.c
> index a85fa08..6f80b6f 100644
> --- a/send-utils.c
> +++ b/send-utils.c
> @@ -486,6 +486,11 @@ struct subvol_info *subvol_uuid_search(struct subvol_uuid_search *s,
>  		info->path = strdup(path);
>  	} else {
>  		info->path = malloc(PATH_MAX);
> +		if (!info->path) {
> +			fprintf(stderr, "Memory allocation failed\n");

Please use the error() helper (does not need \n terminated string).

Also, would be grat to convert subvol_uuid_search to return ERR_PTR
style value (which means to conver all callers). Now we don't see why
exactly it fails and interpret it as nonexistence of the uuid.

      reply	other threads:[~2016-10-06 15:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-05 13:03 [PATCH] Btrfs-progs: subvol_uuid_search: Return error code on memory allocation failure Prasanth K S R
2016-10-06 15:45 ` David Sterba [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=20161006154501.GJ6576@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=dsterba@suse.com \
    --cc=kosigiprasanth@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=prasanth.ksr@dell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).