From patchwork Mon Dec 28 12:43:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 354952 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 6776DC43381 for ; Mon, 28 Dec 2020 14:08:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 32D24205CB for ; Mon, 28 Dec 2020 14:08:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391719AbgL1OI3 (ORCPT ); Mon, 28 Dec 2020 09:08:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:42958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391714AbgL1OI1 (ORCPT ); Mon, 28 Dec 2020 09:08:27 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1134C207AB; Mon, 28 Dec 2020 14:07:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164467; bh=nxCszQ/aXyTvDe3xf/Pz//V2TQyfD+hlBVUEGLZBiwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pQd2IXw7kCg+nPOAskh4cgnrDQrI3bfDhrOkk2O/j2r6ZS7GRNRpKmTMZ/r+ZW2D9 kWdBTgy2CT1t9bOk9SBumrBzl8NjbsijzNCSt98qjiQB9RjP/MoexQmkR2jyt4jUTN CCvF6bFrOTt27gkLNExE2LM67S+sjgB+rPTZL6Q0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Qinglang Miao , Ulf Hansson , Sasha Levin Subject: [PATCH 5.10 191/717] memstick: fix a double-free bug in memstick_check Date: Mon, 28 Dec 2020 13:43:09 +0100 Message-Id: <20201228125030.121361557@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Qinglang Miao [ Upstream commit e3e9ced5c93803d5b2ea1942c4bf0192622531d6 ] kfree(host->card) has been called in put_device so that another kfree would raise cause a double-free bug. Fixes: 0193383a5833 ("memstick: core: fix device_register() error handling") Reported-by: Hulk Robot Signed-off-by: Qinglang Miao Link: https://lore.kernel.org/r/20201120074846.31322-1-miaoqinglang@huawei.com Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/memstick/core/memstick.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c index ef03d6fafc5ce..12bc3f5a6cbbd 100644 --- a/drivers/memstick/core/memstick.c +++ b/drivers/memstick/core/memstick.c @@ -468,7 +468,6 @@ static void memstick_check(struct work_struct *work) host->card = card; if (device_register(&card->dev)) { put_device(&card->dev); - kfree(host->card); host->card = NULL; } } else