From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnd Bergmann 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 Message-ID: <2906898.Fr1ixVkiAI@wuerfel> References: <1417647224-27950-1-git-send-email-VishnuPatekar0510@gmail.com> <12237550.afophX20rO@wuerfel> <63D786FF-B293-4FC1-AD71-D99515DE8E3D@gmail.com> Reply-To: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: In-Reply-To: <63D786FF-B293-4FC1-AD71-D99515DE8E3D-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , To: Dmitry Torokhov Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, vishnupatekar , 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 , jdelvare-l3A5Bk7waGM@public.gmane.org List-Id: linux-input@vger.kernel.org On Friday 05 December 2014 07:01:17 Dmitry Torokhov wrote: > > On December 5, 2014 2:33:11 AM PST, Arnd Bergmann 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: arnd@arndb.de (Arnd Bergmann) Date: Fri, 05 Dec 2014 16:50:18 +0100 Subject: [PATCH 2/3] drivers:input:ps2 Added sunxi A20 ps2 driver, changed makefile and Kconfig In-Reply-To: <63D786FF-B293-4FC1-AD71-D99515DE8E3D@gmail.com> References: <1417647224-27950-1-git-send-email-VishnuPatekar0510@gmail.com> <12237550.afophX20rO@wuerfel> <63D786FF-B293-4FC1-AD71-D99515DE8E3D@gmail.com> Message-ID: <2906898.Fr1ixVkiAI@wuerfel> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Friday 05 December 2014 07:01:17 Dmitry Torokhov wrote: > > On December 5, 2014 2:33:11 AM PST, Arnd Bergmann 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751320AbaLEPu7 (ORCPT ); Fri, 5 Dec 2014 10:50:59 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:62044 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750896AbaLEPu5 (ORCPT ); Fri, 5 Dec 2014 10:50:57 -0500 From: Arnd Bergmann To: Dmitry Torokhov Cc: linux-arm-kernel@lists.infradead.org, vishnupatekar , 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 , 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 Message-ID: <2906898.Fr1ixVkiAI@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <63D786FF-B293-4FC1-AD71-D99515DE8E3D@gmail.com> References: <1417647224-27950-1-git-send-email-VishnuPatekar0510@gmail.com> <12237550.afophX20rO@wuerfel> <63D786FF-B293-4FC1-AD71-D99515DE8E3D@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:9jfGLSWr+cEwb+bcGZursH/YWfrPA/RRwdkTFGD52BuIWHnCxwl 2pFPsqL7BwNkNqU+WFBILDSa9CuVLjj8xtPYKwE1lZcfIHsCT4UNzBPz0nC0vL7KGarvE+r CMuBXf4im0n2D1375PDA50NzKB6msfaNWM/bbd0j7oGnJti+e6QwduHaO3Au4pLHLEJ3mWF YaMp1US/qkrsJqjthJShw== X-UI-Out-Filterresults: notjunk:1; Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday 05 December 2014 07:01:17 Dmitry Torokhov wrote: > > On December 5, 2014 2:33:11 AM PST, Arnd Bergmann 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