All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Denis Kirjanov <kirjanov@gmail.com>
Cc: dougthompson@xmission.com, linux-edac@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] handle error path in edac_mc_sysfs_init()
Date: Thu, 25 Oct 2012 17:56:06 +0200	[thread overview]
Message-ID: <20121025155606.GF308@x1.osrc.amd.com> (raw)
In-Reply-To: <1351179778-6591-1-git-send-email-kirjanov@gmail.com>

On Thu, Oct 25, 2012 at 07:42:58PM +0400, Denis Kirjanov wrote:
> Handle errors on edac_mc_sysfs_init()'s error path
> 
> Signed-off-by: Denis Kirjanov <kirjanov@gmail.com>
> ---
>  drivers/edac/edac_mc_sysfs.c |   14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
> index ed0bc07..ea34ece 100644
> --- a/drivers/edac/edac_mc_sysfs.c
> +++ b/drivers/edac/edac_mc_sysfs.c
> @@ -1124,11 +1124,16 @@ int __init edac_mc_sysfs_init(void)
>  	edac_subsys = edac_get_sysfs_subsys();
>  	if (edac_subsys == NULL) {
>  		edac_dbg(1, "no edac_subsys\n");
> -		return -EINVAL;
> +		err = -EINVAL;
> +		goto out;
>  	}
>  
>  	mci_pdev = kzalloc(sizeof(*mci_pdev), GFP_KERNEL);
> -
> +	if (!mci_pdev) {
> +		err = -ENOMEM;
> +		goto out_put_sysfs;
> +	}
> +		
>  	mci_pdev->bus = edac_subsys;
>  	mci_pdev->type = &mc_attr_type;
>  	device_initialize(mci_pdev);
> @@ -1141,6 +1146,11 @@ int __init edac_mc_sysfs_init(void)
>  	edac_dbg(0, "device %s created\n", dev_name(mci_pdev));

Thanks for doing this.

However, from looking at this function further, it is still f*cked up -
the error path after device_add needs handling too, i.e. adding another
label:

 out_device_add:
 	kfree(mci_pdev);

> +out_put_sysfs:
> +	edac_put_sysfs_subsys();
> +out:
> +	return err;

to which you can goto to after device_add fails.

Would you be willing to fix that too, while you're at it? Btw, I can
totally understand if you say no - I'll take care of it myself instead
then :-).

Thanks.

-- 
Regards/Gruss,
Boris.

  reply	other threads:[~2012-10-25 15:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-25 15:42 [PATCH 1/2] handle error path in edac_mc_sysfs_init() Denis Kirjanov
2012-10-25 15:56 ` Borislav Petkov [this message]
2012-10-25 15:57   ` Borislav Petkov
2012-10-25 16:36     ` Borislav Petkov
2012-10-25 16:48       ` Mauro Carvalho Chehab

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=20121025155606.GF308@x1.osrc.amd.com \
    --to=bp@alien8.de \
    --cc=dougthompson@xmission.com \
    --cc=kirjanov@gmail.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 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.