From patchwork Sun Sep 20 08:37:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 11787373 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 63634112E for ; Sun, 20 Sep 2020 08:43:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E21C221EC for ; Sun, 20 Sep 2020 08:43:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726267AbgITIn1 (ORCPT ); Sun, 20 Sep 2020 04:43:27 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:60224 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726255AbgITIn0 (ORCPT ); Sun, 20 Sep 2020 04:43:26 -0400 X-Greylist: delayed 335 seconds by postgrey-1.27 at vger.kernel.org; Sun, 20 Sep 2020 04:43:25 EDT Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 893A71C0B9B; Sun, 20 Sep 2020 10:37:46 +0200 (CEST) Date: Sun, 20 Sep 2020 10:37:45 +0200 From: Pavel Machek To: wim@linux-watchdog.org, linux@roeck-us.net, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] watchdog: fix memory leak in error path Message-ID: <20200920083745.GA1186@amd> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Fix memory leak in error path. Signed-off-by: Pavel Machek (CIP) diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index 6798addabd5a..785270ee337c 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -994,8 +994,10 @@ static int watchdog_cdev_register(struct watchdog_device *wdd) wd_data->wdd = wdd; wdd->wd_data = wd_data; - if (IS_ERR_OR_NULL(watchdog_kworker)) + if (IS_ERR_OR_NULL(watchdog_kworker)) { + kfree(wd_data); return -ENODEV; + } device_initialize(&wd_data->dev); wd_data->dev.devt = MKDEV(MAJOR(watchdog_devt), wdd->id);