Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753012AbdHUJml (ORCPT ); Mon, 21 Aug 2017 05:42:41 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:37935 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751172AbdHUJmk (ORCPT ); Mon, 21 Aug 2017 05:42:40 -0400 Reply-To: monstr@monstr.eu Subject: Re: [PATCH] alarmtimer: ensure RTC module is not unloaded To: Alexandre Belloni , Thomas Gleixner , John Stultz Cc: Stephen Boyd , linux-kernel@vger.kernel.org References: <20170820220146.30969-1-alexandre.belloni@free-electrons.com> From: Michal Simek Message-ID: <04526996-001f-6f78-8053-15b4bb665cc5@monstr.eu> Date: Mon, 21 Aug 2017 11:42:31 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170820220146.30969-1-alexandre.belloni@free-electrons.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="PG8BMWjuVLQ1hQkAad2dAQldT2LoDVXhg" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2927 Lines: 92 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --PG8BMWjuVLQ1hQkAad2dAQldT2LoDVXhg Content-Type: multipart/mixed; boundary="MTRUiMiB5LqcOfS3V6J1u7j4xBOCI7cxF"; protected-headers="v1" From: Michal Simek Reply-To: monstr@monstr.eu To: Alexandre Belloni , Thomas Gleixner , John Stultz Cc: Stephen Boyd , linux-kernel@vger.kernel.org Message-ID: <04526996-001f-6f78-8053-15b4bb665cc5@monstr.eu> Subject: Re: [PATCH] alarmtimer: ensure RTC module is not unloaded References: <20170820220146.30969-1-alexandre.belloni@free-electrons.com> In-Reply-To: <20170820220146.30969-1-alexandre.belloni@free-electrons.com> --MTRUiMiB5LqcOfS3V6J1u7j4xBOCI7cxF Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 21.8.2017 00:01, Alexandre Belloni wrote: > When registering the rtc device to be used to handle alarm timers, > get_device is used to ensure the device doesn't go away but the module = can > still be unloaded. Call try_module_get to ensure the rtc driver will no= t go > away. >=20 > Reported-by: Michal Simek > Signed-off-by: Alexandre Belloni = > --- > kernel/time/alarmtimer.c | 6 ++++++ > 1 file changed, 6 insertions(+) >=20 > diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c > index 0b8ff7d257ea..1c682eef7e6b 100644 > --- a/kernel/time/alarmtimer.c > +++ b/kernel/time/alarmtimer.c > @@ -28,6 +28,7 @@ > #include > #include > #include > +#include > =20 > #include "posix-timers.h" > =20 > @@ -100,6 +101,11 @@ static int alarmtimer_rtc_add_device(struct device= *dev, > =20 > spin_lock_irqsave(&rtcdev_lock, flags); > if (!rtcdev) { > + if (!try_module_get(rtc->owner)) { > + spin_unlock_irqrestore(&rtcdev_lock, flags); > + return -1; > + } > + > rtcdev =3D rtc; > /* hold a reference so it doesn't go away */ > get_device(dev); >=20 Tested-by: Michal Simek Thanks, Michal --=20 Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP SoCs --MTRUiMiB5LqcOfS3V6J1u7j4xBOCI7cxF-- --PG8BMWjuVLQ1hQkAad2dAQldT2LoDVXhg Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iEYEARECAAYFAlmaqwcACgkQykllyylKDCGLOgCfYAapS/kb1R7WXqK97o7MRPaz nEAAn3g8g9dDsE3ihO1ZMAXhTMu3p6Zc =VmgN -----END PGP SIGNATURE----- --PG8BMWjuVLQ1hQkAad2dAQldT2LoDVXhg--