Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2151960iof; Tue, 7 Jun 2022 21:29:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSDZed1pYUTQ6BrWUGALiO5WbcMygJScZrUekYWbZ9935t+tpdeMsTsnURanoEF/dXwGqA X-Received: by 2002:a05:6a00:cd2:b0:51c:28b5:1573 with SMTP id b18-20020a056a000cd200b0051c28b51573mr11171567pfv.59.1654662591911; Tue, 07 Jun 2022 21:29:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654662591; cv=none; d=google.com; s=arc-20160816; b=k25ODzMA6XmH35T26Vozii2njX/jT8W58hJewbT2SojGKyaO7wyO0F1UoRKS41y6I7 9fJoLSpvoOEJGegb49naQC0H2zwGz+9yf4EppXXLWIZJ2yramS+FVGBPnbUcL9FmMIjY g7NwJy0m+ssAnzxLMUNwLFhNx6ikrToO4DmH0f2L2FYmdeh+nxT+wp3UON1HZ8/VbW6j +4JwrqT+MWrmPPGzUFzufOVpWdUaQZZLkb3T/CyVnyIKPr5FSwWSahFhce0OS2inGFh6 WJBe4kKQEv9+hhMdt0DZCl8VWh9JAnyalih6s3FCYy6NTDM1aqWQKYoF+yOUlhiiJWci BTWA== 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=SBQzFomissCQ0CT16k9yprlvypW37SaMuVvdnRybTS4=; b=dqvCi6LDtxlj2JwSqTjoKhbqDRbrq/W8QArvlslITd/3LriW9K5iLrfdRmxQN01IKk x342blnGv6rxuVtsF3BvFZHb4oNPN/qjjzdeKQafiUUeJfmNay+JJ/qJmsqQbp5Hl8DW pY13fKi+MoiCq/uRGolkM05e1hEbu+u1IsdKP0e8QPa4MxPmMcu2Ei9K3BX+nHa+ol4E l0l2UHHxHn3Ug6L9FxBR2mdkkARPVnbWPZ5ZkpkkTq1awex6qPdwwf1IYlP64KT+HCBv ktxw25tH0MlFPyC8kDcYnBai8mf9jOJRh2mU3LR1tf6M5xm0TymfMFYVQQwSdBUoUjuW b4Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="DzMV/gAy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z15-20020a65610f000000b003fc590f41fdsi23957068pgu.605.2022.06.07.21.29.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:29:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="DzMV/gAy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 372A739F26B; Tue, 7 Jun 2022 20:58:28 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348801AbiFGRyy (ORCPT + 99 others); Tue, 7 Jun 2022 13:54:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347687AbiFGRfo (ORCPT ); Tue, 7 Jun 2022 13:35:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94FA2BC6F8; Tue, 7 Jun 2022 10:31:07 -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 ams.source.kernel.org (Postfix) with ESMTPS id 73D17B8220B; Tue, 7 Jun 2022 17:30:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF667C385A5; Tue, 7 Jun 2022 17:30:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654623058; bh=2D9KikUe9oTYeuBe7GwvUaWVp/nisnI0acN44yzsfe8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DzMV/gAy8aL0Fjp/IkuZmsg1MOnzfE8cRdNuFLPw9bttx5wxq3oQ+dC1DrdImZIfx Lwyog4l8tHLQBUr6UjQWOqyzufQWYFR6CjhivRMgMrdYXce+qwhO3Cc4g05kcoHlVs eymyKu2d2fFuViUi3syIo1uVlYmWUoutwcWLQQ5E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hangyu Hua , Frederic Barrat , Michael Ellerman , Sasha Levin Subject: [PATCH 5.10 279/452] misc: ocxl: fix possible double free in ocxl_file_register_afu Date: Tue, 7 Jun 2022 19:02:16 +0200 Message-Id: <20220607164916.863717390@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hangyu Hua [ Upstream commit 950cf957fe34d40d63dfa3bf3968210430b6491e ] info_release() will be called in device_unregister() when info->dev's reference count is 0. So there is no need to call ocxl_afu_put() and kfree() again. Fix this by adding free_minor() and return to err_unregister error path. Fixes: 75ca758adbaf ("ocxl: Create a clear delineation between ocxl backend & frontend") Signed-off-by: Hangyu Hua Acked-by: Frederic Barrat Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220418085758.38145-1-hbh25y@gmail.com Signed-off-by: Sasha Levin --- drivers/misc/ocxl/file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c index 4d1b44de1492..c742ab02ae18 100644 --- a/drivers/misc/ocxl/file.c +++ b/drivers/misc/ocxl/file.c @@ -558,7 +558,9 @@ int ocxl_file_register_afu(struct ocxl_afu *afu) err_unregister: ocxl_sysfs_unregister_afu(info); // safe to call even if register failed + free_minor(info); device_unregister(&info->dev); + return rc; err_put: ocxl_afu_put(afu); free_minor(info); -- 2.35.1