From patchwork Tue Oct 27 13:53:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 307008 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 DF6D1C55178 for ; Tue, 27 Oct 2020 17:51:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A64A24181 for ; Tue, 27 Oct 2020 17:51:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603821077; bh=x4/W+EqyE8cRLC70C0gguX4Izs1KXoSwMfj8JfATk8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=a2uHvRp0YHe5MNp1rEuZyTuEqa7xGeeeXFhiD7ZbPJz/wpucF8hgrAq9NUUeeMtpv w3JAGImvJJpdEaVJ27QwaNroGs5fsPpoJbNecSKQ26/qnztbQ7IJ8+6RoMc+7mQ8bD nivaiCH6/Y/aKwd4ikNkl2gGBw41VIubx8wz4XH0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758773AbgJ0OYY (ORCPT ); Tue, 27 Oct 2020 10:24:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:49632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754014AbgJ0OYX (ORCPT ); Tue, 27 Oct 2020 10:24:23 -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 9D68220773; Tue, 27 Oct 2020 14:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603808663; bh=x4/W+EqyE8cRLC70C0gguX4Izs1KXoSwMfj8JfATk8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ycEbNV7CwWJB1usDwVx5uOiEkA+ey0RG8o51MHqS0mnfX11OmRK3QTBECpn0Dhv2g JXoXNe9b3VcJ8HSeGg+xUvnH2NJJI1ObEtZMo/ovrV3+5jwxj9ar76SrxhjtJ+IwEL RFwLkv2s1DfK6qwMCfu4Rqzh4WgNOLzzTILex5vM= 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 4.19 175/264] watchdog: Use put_device on error Date: Tue, 27 Oct 2020 14:53:53 +0100 Message-Id: <20201027135438.902025761@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135430.632029009@linuxfoundation.org> References: <20201027135430.632029009@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 1e4921f89fb52..8fe59b7d8eec8 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -973,7 +973,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; } }