From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFAA0C433F5 for ; Tue, 5 Apr 2022 07:41:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231915AbiDEHnC (ORCPT ); Tue, 5 Apr 2022 03:43:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231852AbiDEHlw (ORCPT ); Tue, 5 Apr 2022 03:41:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4985F4B859; Tue, 5 Apr 2022 00:39:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7B2E06164B; Tue, 5 Apr 2022 07:39:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 871B9C340EE; Tue, 5 Apr 2022 07:39:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649144386; bh=TiyLQ3K6thQvViES3Dvp4/W4jR7z6kpaRENWn8GKzJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BkgXK/ymQn9M+cnP8ErigFvoS772JP/RJn6/hPLMmgdyM1WWu8F2+gi7I+tuvrV+J 8pXQ+LUFqTn0+xFMfA3u+yasQmLRwWKSAU7Cb/S6xvtoCXwQAMjHvxdNC1XlfQzFhC pFlsfSKb3/6Jn3peWe4q/QlGz/nPEaEGIlq+w7Jk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Mathieu Poirier , Suzuki K Poulose Subject: [PATCH 5.17 0027/1126] coresight: syscfg: Fix memleak on registration failure in cscfg_create_device Date: Tue, 5 Apr 2022 09:12:54 +0200 Message-Id: <20220405070408.348567576@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@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: Miaoqian Lin commit cfa5dbcdd7aece76f3415284569f2f384aff0253 upstream. device_register() calls device_initialize(), according to doc of device_initialize: Use put_device() to give up your reference instead of freeing * @dev directly once you have called this function. To prevent potential memleak, use put_device() for error handling. Signed-off-by: Miaoqian Lin Fixes: 85e2414c518a ("coresight: syscfg: Initial coresight system configuration") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220124124121.8888-1-linmq006@gmail.com Signed-off-by: Mathieu Poirier Signed-off-by: Suzuki K Poulose Signed-off-by: Greg Kroah-Hartman --- drivers/hwtracing/coresight/coresight-syscfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/hwtracing/coresight/coresight-syscfg.c +++ b/drivers/hwtracing/coresight/coresight-syscfg.c @@ -1049,7 +1049,7 @@ static int cscfg_create_device(void) err = device_register(dev); if (err) - cscfg_dev_release(dev); + put_device(dev); create_dev_exit_unlock: mutex_unlock(&cscfg_mutex);