All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
To: Dmitry Torokhov
	<dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	vishnupatekar
	<vishnupatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org,
	linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	vishnupatekar
	<VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	jdelvare-l3A5Bk7waGM@public.gmane.org
Subject: Re: [PATCH 2/3] drivers:input:ps2 Added sunxi A20 ps2 driver, changed makefile and Kconfig
Date: Fri, 05 Dec 2014 16:50:18 +0100	[thread overview]
Message-ID: <2906898.Fr1ixVkiAI@wuerfel> (raw)
In-Reply-To: <63D786FF-B293-4FC1-AD71-D99515DE8E3D-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On Friday 05 December 2014 07:01:17 Dmitry Torokhov wrote:
> 
> On December 5, 2014 2:33:11 AM PST, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote:
> >On Thursday 04 December 2014 04:23:44 vishnupatekar wrote:
> >> +
> >> +struct sunxips2data {
> >> +    int irq;
> >> +    spinlock_t ps2_lock;
> >> +    void __iomem *base_address;     /* virt address of control registers*/
> >> +    struct serio *serio;            /* serio*/
> >> +    struct device *dev;
> >> +    struct  clk     *pclk;
> >> +};
> >
> >As this is dynamically allocated, better embed the serio member
> >directly to avoid allocating both separately.
> 
> That would be wrong - serio is refcounted and it may outlive instance of sunxips2data you embedded it into.

Ok, I see. I guess in this case the use of devm_kzalloc for serio is a bug,
because that would lead to a double free upon module unload, right?

	Arnd

WARNING: multiple messages have this Message-ID (diff)
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] drivers:input:ps2 Added sunxi A20 ps2 driver, changed makefile and Kconfig
Date: Fri, 05 Dec 2014 16:50:18 +0100	[thread overview]
Message-ID: <2906898.Fr1ixVkiAI@wuerfel> (raw)
In-Reply-To: <63D786FF-B293-4FC1-AD71-D99515DE8E3D@gmail.com>

On Friday 05 December 2014 07:01:17 Dmitry Torokhov wrote:
> 
> On December 5, 2014 2:33:11 AM PST, Arnd Bergmann <arnd@arndb.de> wrote:
> >On Thursday 04 December 2014 04:23:44 vishnupatekar wrote:
> >> +
> >> +struct sunxips2data {
> >> +    int irq;
> >> +    spinlock_t ps2_lock;
> >> +    void __iomem *base_address;     /* virt address of control registers*/
> >> +    struct serio *serio;            /* serio*/
> >> +    struct device *dev;
> >> +    struct  clk     *pclk;
> >> +};
> >
> >As this is dynamically allocated, better embed the serio member
> >directly to avoid allocating both separately.
> 
> That would be wrong - serio is refcounted and it may outlive instance of sunxips2data you embedded it into.

Ok, I see. I guess in this case the use of devm_kzalloc for serio is a bug,
because that would lead to a double free upon module unload, right?

	Arnd

WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org,
	vishnupatekar <vishnupatekar0510@gmail.com>,
	maxime.ripard@free-electrons.com, linux-sunxi@googlegroups.com,
	devicetree@vger.kernel.org, benh@kernel.crashing.org,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	ralf@linux-mips.org, robh+dt@kernel.org, msalter@redhat.com,
	vishnupatekar <VishnuPatekar0510@gmail.com>,
	jdelvare@suse.de
Subject: Re: [PATCH 2/3] drivers:input:ps2 Added sunxi A20 ps2 driver, changed makefile and Kconfig
Date: Fri, 05 Dec 2014 16:50:18 +0100	[thread overview]
Message-ID: <2906898.Fr1ixVkiAI@wuerfel> (raw)
In-Reply-To: <63D786FF-B293-4FC1-AD71-D99515DE8E3D@gmail.com>

On Friday 05 December 2014 07:01:17 Dmitry Torokhov wrote:
> 
> On December 5, 2014 2:33:11 AM PST, Arnd Bergmann <arnd@arndb.de> wrote:
> >On Thursday 04 December 2014 04:23:44 vishnupatekar wrote:
> >> +
> >> +struct sunxips2data {
> >> +    int irq;
> >> +    spinlock_t ps2_lock;
> >> +    void __iomem *base_address;     /* virt address of control registers*/
> >> +    struct serio *serio;            /* serio*/
> >> +    struct device *dev;
> >> +    struct  clk     *pclk;
> >> +};
> >
> >As this is dynamically allocated, better embed the serio member
> >directly to avoid allocating both separately.
> 
> That would be wrong - serio is refcounted and it may outlive instance of sunxips2data you embedded it into.

Ok, I see. I guess in this case the use of devm_kzalloc for serio is a bug,
because that would lead to a double free upon module unload, right?

	Arnd

  parent reply	other threads:[~2014-12-05 15:50 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-03 22:53 [PATCH 2/3] drivers:input:ps2 Added sunxi A20 ps2 driver, changed makefile and Kconfig vishnupatekar
2014-12-03 22:53 ` vishnupatekar
2014-12-03 22:53 ` vishnupatekar
2014-12-05 10:01 ` Maxime Ripard
2014-12-05 10:01   ` Maxime Ripard
2014-12-06 13:31   ` Vishnu Patekar
     [not found] ` <1417647224-27950-1-git-send-email-VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-12-03 23:23   ` Dmitry Torokhov
2014-12-03 23:23     ` Dmitry Torokhov
2014-12-03 23:23     ` Dmitry Torokhov
2014-12-04  3:08     ` Vishnu Patekar
2014-12-05 10:33   ` Arnd Bergmann
2014-12-05 10:33     ` Arnd Bergmann
2014-12-05 10:33     ` Arnd Bergmann
2014-12-05 15:01     ` Dmitry Torokhov
2014-12-05 15:01       ` Dmitry Torokhov
2014-12-05 15:01       ` Dmitry Torokhov
     [not found]       ` <63D786FF-B293-4FC1-AD71-D99515DE8E3D-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-12-05 15:50         ` Arnd Bergmann [this message]
2014-12-05 15:50           ` Arnd Bergmann
2014-12-05 15:50           ` Arnd Bergmann
2014-12-05 15:53           ` Dmitry Torokhov
2014-12-05 15:53             ` Dmitry Torokhov
2014-12-05 15:53             ` Dmitry Torokhov

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=2906898.Fr1ixVkiAI@wuerfel \
    --to=arnd-r2ngtmty4d4@public.gmane.org \
    --cc=benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=jdelvare-l3A5Bk7waGM@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    --cc=maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=vishnupatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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.