Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp517691pxx; Wed, 28 Oct 2020 10:07:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvtc0SnNgy81sMujC0H5jjg/A6s6Xcw+moevvHLkSLDJWFk8acYj05hjM1PXBYFGUPn5/6 X-Received: by 2002:a1c:bdc4:: with SMTP id n187mr385290wmf.185.1603904866517; Wed, 28 Oct 2020 10:07:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603904866; cv=none; d=google.com; s=arc-20160816; b=SQYmzabBxgvMU9y3ZqHwfOILGK+aC57LxEiqs0hbgwdgXw3ou7nN9O2HN495hFCv0b YnzAw8pGj3w0a+k+q5vYvjgebWYvtQdnK+pmAEO2ANo1Zp/tVUHMw/UHE6v5VnnDYdHX bmoVty1aHIeerPk5hwXy4MtDxM44KfCG/YNGBfxTDxD57TemNbecmEh+VEcLbX/sMwPy fUI0WQAiv27VKgfKZ23SDIssJIgi0x1oQsMMugC2aJekgMgRaN6k1XM3ClAXPZnWf74D DKUyZsHKCRW+PZ47GbCe7TqrdWMIjtp+usJYJ8gHCn3AYIY6mofDGeQhlPnjvYZR0R0U nrAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZvdDRTzYnc5zPxbkz92XjJ6I1Ujps8jsC4ZkOPIrv1A=; b=GP38o/pjsHxZakzWIwvzcK6PsMbHmhbPp6fysUHMMTKxRtnu886g2bi1dEEwWBF9AY +VaclYC7HKDJglbZcFig3S8CX4Wepei36AU0Js3V3e31ajIGT/OS9PPZuXh9DJqY8u2x NcBlBdUIYpGCKkge/5zCuSUXawYxDz3RbsGiO5f3z44/+5VegoZZuNvCki6/8FO3XsjO t+p4I9w5Zk9GFCQI0nIYjCHkzO0f3XKMrs1sn7ZOORE/EIv+Ho6zg36Wja8cdkGfTpna +lCAGCFY6Qo7Aj6FbIA/qpAQUdyC4SvrWSyhCUMaanaDdnbQo//Azh9ZaBJBPI1kBntL N8lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bPyfLNLK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i9si3854304eje.410.2020.10.28.10.07.07; Wed, 28 Oct 2020 10:07:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bPyfLNLK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1820112AbgJ0Rcz (ORCPT + 99 others); Tue, 27 Oct 2020 13:32:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:40442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762132AbgJ0OlG (ORCPT ); Tue, 27 Oct 2020 10:41:06 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 095A521D7B; Tue, 27 Oct 2020 14:41:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809665; bh=5ITvGLh7cmNRzaQQCfWDbV+p582wr5qCJGYBgVrmkDM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bPyfLNLKSuW4NR1qjjdI8ADC5fuEg3E7rk6+9+l6hDSoATmAHQxqBaij2CdE71Vgk XqGPkR2saUnCdn9YFGn9mIcufMRYg7UydWHQ7qa0kG3nIFiD22fADLO8nlS8p5lJfr kvUA2zIyHUpU7UVscYMcipTL6z3YzvZChx4C30Ro= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dinghao Liu , Guenter Roeck , Wim Van Sebroeck , Sasha Levin Subject: [PATCH 5.4 275/408] watchdog: Fix memleak in watchdog_cdev_register Date: Tue, 27 Oct 2020 14:53:33 +0100 Message-Id: <20201027135507.810582527@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dinghao Liu [ Upstream commit 5afb6d203d0293512aa2c6ae098274a2a4f6ed02 ] When watchdog_kworker is NULL, we should free wd_data before the function returns to prevent memleak. Fixes: 664a39236e718 ("watchdog: Introduce hardware maximum heartbeat in watchdog core") Signed-off-by: Dinghao Liu Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20200824024001.25474-1-dinghao.liu@zju.edu.cn Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Sasha Levin --- drivers/watchdog/watchdog_dev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index 3729f99fd8eca..694357f2816b3 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -971,8 +971,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); -- 2.25.1