From patchwork Tue Oct 27 13:53:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 307090 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84D61C5DF9E for ; Tue, 27 Oct 2020 17:35:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D12B208B8 for ; Tue, 27 Oct 2020 17:35:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603820147; bh=vCRqwvqes9Ejty9PXANcAb0O2tpfPAgPoRQIacUAnWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=z7EFZcP4oWi+z7FJz/p31mpLiOF1IE3SNG/qmED9r8Yauonak3BeHvF3B+7d9i4Cb D3hSHYuRPxlV/OVVnWI0CCOgA1iPjFBf0Cqxfl9yU8tEWt19nnMFKGH/yKgUqlSEXo k6MTM3HbGnrSWAV+1Q2sKGKpdQjVNiOmKAO0dyeY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1819952AbgJ0Rbl (ORCPT ); Tue, 27 Oct 2020 13:31:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:40506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1749907AbgJ0OlI (ORCPT ); Tue, 27 Oct 2020 10:41:08 -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 C37322225E; Tue, 27 Oct 2020 14:41:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809668; bh=vCRqwvqes9Ejty9PXANcAb0O2tpfPAgPoRQIacUAnWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f4rBk9nNJwQXYHJiTppjiRvTFKZI64/ugTC4STDIv/Nb+6wDsQzJDnwthme43OH94 NLtBkqL9xT9lrAozF+jbac0GGIKwLFQpiJYSq2o8+EIqA4hRew4awJS2S6xWx/ZOLI sqyRPAcYN/YU6uylBJ6i1cnRJBIBeHe+ilvM0jGY= 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 276/408] watchdog: Use put_device on error Date: Tue, 27 Oct 2020 14:53:34 +0100 Message-Id: <20201027135507.851065639@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 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dinghao Liu [ Upstream commit 937425d4cd3ae4e2882b41e332bbbab616bcf0ad ] We should use put_device() instead of freeing device directly after device_initialize(). Fixes: cb36e29bb0e4b ("watchdog: initialize device before misc_register") Signed-off-by: Dinghao Liu Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20200824031230.31050-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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index 694357f2816b3..8494846ccdc5f 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -1000,7 +1000,7 @@ static int watchdog_cdev_register(struct watchdog_device *wdd) pr_err("%s: a legacy watchdog module is probably present.\n", wdd->info->identity); old_wd_data = NULL; - kfree(wd_data); + put_device(&wd_data->dev); return err; } }