All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tzung-Bi Shih <tzungbi@google.com>
To: Prashant Malani <pmalani@chromium.org>
Cc: bleung@chromium.org, groeck@chromium.org,
	chrome-platform@lists.linux.dev
Subject: Re: [PATCH v2 1/6] platform/chrome: cros_ec: fix error handling in cros_ec_register()
Date: Wed, 9 Feb 2022 17:35:29 +0800	[thread overview]
Message-ID: <YgOK4eCGzi/g61yU@google.com> (raw)
In-Reply-To: <CACeCKadDh0+nTXEy6xC98QLBciD78Oy4DH2749-BfAQ2fBpNXw@mail.gmail.com>

On Tue, Feb 08, 2022 at 09:38:55PM -0800, Prashant Malani wrote:
> On Tue, Feb 8, 2022 at 8:50 PM Tzung-Bi Shih <tzungbi@google.com> wrote:
> >
> > Fix cros_ec_register() doesn't unregister platform devices if
> > blocking_notifier_chain_register() fails.
> 
> This isn't grammatically correct. Instead:
> Fix cros_ec_register() to unregister platform devices if blocking....

Thanks, will fix in next version.

> > Also use the single exit path to handle the platform device
> > unregistration.
> >
> > This fix depends on the fact that all the callers of cros_ec_register()
> > allocate zeroed memory.
> 
> Is that a fair assumption? What happens if a future driver calls
> cros_ec_register()
> without zeroed memory?

Suppose ec_dev->pd is garbage data, platform_device_unregister() will operate
on invalid memory address.

Let's use another guard condition in next version instead of relying on
zeroed memory.

> > ---
> What has changed since v2? Please add a change log of the versions here.

They are in the cover letter actually.  Will copy them to each patch.

> > @@ -291,6 +289,12 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
> >                 cros_ec_irq_thread(0, ec_dev);
> >
> >         return 0;
> > +exit:
> > +       if (!IS_ERR_OR_NULL(ec_dev->pd))
> > +               platform_device_unregister(ec_dev->pd);
> > +       if (!IS_ERR_OR_NULL(ec_dev->ec))
> > +               platform_device_unregister(ec_dev->ec);
> > +       return err;
> You don't need these "if" checks. They are already performed by
> platform_device_unregister(), or rather, the functions that it calls [1][2].

Ack, will remove the check in next version.

  reply	other threads:[~2022-02-09  9:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09  4:50 [PATCH v2 0/6] platform/chrome: cros_ec: miscellaneous cleanups Tzung-Bi Shih
2022-02-09  4:50 ` [PATCH v2 1/6] platform/chrome: cros_ec: fix error handling in cros_ec_register() Tzung-Bi Shih
2022-02-09  5:38   ` Prashant Malani
2022-02-09  9:35     ` Tzung-Bi Shih [this message]
2022-02-09  4:50 ` [PATCH v2 2/6] platform/chrome: cros_ec: remove unused variable `was_wake_device` Tzung-Bi Shih
2022-02-09  5:58   ` Prashant Malani
2022-02-09  9:36     ` Tzung-Bi Shih
2022-02-09  4:50 ` [PATCH v2 3/6] platform/chrome: cros_ec: determine `wake_enabled` in cros_ec_suspend() Tzung-Bi Shih
2022-02-09  6:05   ` Prashant Malani
2022-02-09  9:36     ` Tzung-Bi Shih
2022-02-16  1:07       ` Prashant Malani
2022-02-16  4:13         ` Tzung-Bi Shih
2022-02-16  5:55           ` Prashant Malani
2022-02-16  7:33             ` Tzung-Bi Shih
2022-02-09  4:50 ` [PATCH v2 4/6] platform/chrome: cros_ec: don't initialize `err` in cros_ec_register() Tzung-Bi Shih
2022-02-09  6:08   ` Prashant Malani
2022-02-09  9:37     ` Tzung-Bi Shih
2022-02-09  4:50 ` [PATCH v2 5/6] platform/chrome: cros_ec: sort header inclusion alphabetically Tzung-Bi Shih
2022-02-09  4:50 ` [PATCH v2 6/6] platform/chrome: cros_ec: append newline to all logs Tzung-Bi Shih

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=YgOK4eCGzi/g61yU@google.com \
    --to=tzungbi@google.com \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=groeck@chromium.org \
    --cc=pmalani@chromium.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.