Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp370822ybg; Tue, 22 Oct 2019 22:38:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqywJQZEamxdPaOYMuTjh8FKhA7cr2iMT7Pwf8KX/fnwtjbP6l9CTtAGqj7OFdlM9q3V/4Tg X-Received: by 2002:a05:6402:170e:: with SMTP id y14mr35437280edu.82.1571809103281; Tue, 22 Oct 2019 22:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571809103; cv=none; d=google.com; s=arc-20160816; b=DgEkZ+QT86QEokzaEuYOYdpYlBP9c9e0efkl2ETyO0hIxGy+KWFURlJnKcrXibqVVG 1xdgVDYZWcGevjNwWmLqpJhVm9KYnN5dgIE/p2WCTqTab7mMqu6ORzhUqIoA7qF2Q/FP B0z9YLzPk3j8IEy+vWn0RF+SYxSEAkHqyUNSp+Tp9N0OS92HDTfjrxq6CzUsThGf4N5t bO5iff/5NylUa8lGg81grEFJNU4Z7hKpIOd0EHIy92F/N+DZut8xtxa8a81aB7+Wpzgv RcV74NsDRQ1eyIGH6LAojsz/ZTYKMAdlGHVjRFpHaiQ0oSWdKz3Ten28zkjUQlXppUbS vtRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=OKxxrxrRmQ9OEs+TDHwbhEPuOlHTRldEW91bPkMwe+Q=; b=Zz/hLDrYcVnKVFvNerA7UWdtZgo0OsVWXFnyqOmCvcdreMEG/t78YwjX4NBlqnfv6R C+oa4jxeQNTZrepUVYYpuCsJbAMRx21mZUAM0NInT4xWqE3Hbgzayyuc0mq20JK3Ou4H gPQnBuqkgAbG3OPEMojbCpOoCtTXJwbys9Y2A+V6FK/pHlUNYoIMF/zoSnb47T0bV3Hw tyoininKP9ZMKmwyIvEO6ExzOo5My+N3FE68LUJi2NwEKsjkigWlpX989kfABh88Xubl MICSs4Akqbg4BJp5Pn+G7Xs4JThtbEPgjyHtLjRASv81S6tjbf2H61UONrjT2l3ttaIb H42w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IRpEwZZl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m33si13923706edc.94.2019.10.22.22.37.59; Tue, 22 Oct 2019 22:38:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IRpEwZZl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732883AbfJWEvJ (ORCPT + 99 others); Wed, 23 Oct 2019 00:51:09 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:37153 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731061AbfJWEvI (ORCPT ); Wed, 23 Oct 2019 00:51:08 -0400 Received: by mail-io1-f66.google.com with SMTP id 1so11981579iou.4; Tue, 22 Oct 2019 21:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=OKxxrxrRmQ9OEs+TDHwbhEPuOlHTRldEW91bPkMwe+Q=; b=IRpEwZZlH/NAmDOc3Du/eDq/g+6Akr2uQN+kUqqLGi0wZTRTzWoKAPqu9spG3AFt5C 5juvxtVr6WBPWT4HaSsFXNSytOWs1BOd59LjkzyUNpWOBrwfcifGhbnB+sfIYJuXCIq1 1l/3l5qvC3626rlS1xRPCcTwJ9+ksmo3D3b4kcW9+Kf8x8HL60Ojp/8024pg0XDqINi+ VXXoKRVxuItscwoVyM8fjc8FlpWMmw+ydN4eD83AxEKSaQumjs/101MqmW9BgSMvVFbW fbTb0EQHTQpxT12fe4hi3g18dPuawSTN8ZIclIeRxsy3xxiW9vNf8gTGSlVbbcb9sGCm rqnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=OKxxrxrRmQ9OEs+TDHwbhEPuOlHTRldEW91bPkMwe+Q=; b=Xfms6utAeQMITGKZL8+t3/y0170rCaXK2o9zewWjbuRWsSCyF9pu58pw8uIxxVXByi yuBinG5CYwo8AjFXl8Em9gZ6ooSyoUmv2+e1QDq7gNZjtdVOSCZ8FUfxq2pfmefdThk9 btGqe0jhpNen8ykV86P74AO3ss8KbxZuoaykN3bbgVHXgtin82PU607lw+xgIwmKF2y1 BhBRipfVyuyfIR+9ZMB1+x7GJnOKNCeKjrLapFD4tHMPBh0Zy7oyePDcdT/h6USNxxHB fNp+NGrXM3HvCf6XliS7X3E0ABBKKpTrjqGxKJILfJw1BxiuN16i5xp/jY+nEvnEskGT P14w== X-Gm-Message-State: APjAAAVx4ycdcFK5reEhmr7SeLH4fURmDOru4vPUwqlBBOE/9bpWMCol pzk/tYHostu8x1em1dUGCpkcdSk3VtZmOi467N8= X-Received: by 2002:a05:6638:632:: with SMTP id h18mr7358032jar.107.1571806266511; Tue, 22 Oct 2019 21:51:06 -0700 (PDT) MIME-Version: 1.0 References: <20191021201848.4231-1-navid.emamdoost@gmail.com> <2a6cdb63-397b-280a-7379-740e8f43ddf6@xilinx.com> In-Reply-To: <2a6cdb63-397b-280a-7379-740e8f43ddf6@xilinx.com> From: Navid Emamdoost Date: Tue, 22 Oct 2019 23:50:55 -0500 Message-ID: Subject: Re: [PATCH] clocksource/drivers: Fix memory leak in ttc_setup_clockevent To: Michal Simek Cc: Markus Elfring , linux-arm-kernel@lists.infradead.org, LKML , kernel-janitors@vger.kernel.org, Navid Emamdoost , Kangjie Lu , Stephen McCamant , Daniel Lezcano , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for the feedback, I updated this patch and sent v2. Also, I submitted a patch to fix the error handling path in ttc_setup_clocksource(). Here is the link to it: https://lore.kernel.org/patchwork/patch/1143242/ On Tue, Oct 22, 2019 at 3:51 AM Michal Simek wrot= e: > > On 22. 10. 19 10:26, Markus Elfring wrote: > >> In the impelementation of ttc_setup_clockevent() the allocated memory > >> for ttcce should be released if clk_notifier_register() fails. > > > > * Please avoid the copying of typos from previous change descriptions. > > > > * Under which circumstances will an =E2=80=9Cimperative mood=E2=80=9D m= atter for you here? > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tr= ee/Documentation/process/submitting-patches.rst?id=3D7d194c2100ad2a6dded545= 887d02754948ca5241#n151 > > > > > >> +++ b/drivers/clocksource/timer-cadence-ttc.c > >> @@ -424,6 +424,7 @@ static int __init ttc_setup_clockevent(struct clk = *clk, > >> &ttcce->ttc.clk_rate_change_nb); > >> if (err) { > >> pr_warn("Unable to register clock notifier.\n"); > >> + kfree(ttcce); > >> return err; > >> } > > > > This addition looks correct. > > But I would prefer to move such exception handling code to the end of > > this function implementation so that duplicate source code will be redu= ced. > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree= /Documentation/process/coding-style.rst?id=3D7d194c2100ad2a6dded545887d0275= 4948ca5241#n450 > > Just a note. Maybe you should also consider to fix this error path in > ttc_setup_clocksource() when notifier also can fail that there is no > need to continue with code execution. > > Thanks, > Michal --=20 Navid.