Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9173843pxu; Mon, 28 Dec 2020 08:24:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzAT/92wIdY/EKOHU26rLILdoes65ooH/BspfVDt1btz/ubIhl2Mx+6RCEdtsCgbNWHDB4q X-Received: by 2002:a17:906:2499:: with SMTP id e25mr42307406ejb.446.1609172678329; Mon, 28 Dec 2020 08:24:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609172678; cv=none; d=google.com; s=arc-20160816; b=YjclNLgRiFCLbgqbP4ZyIQgRQR8tfKeKRp5GYDdDnjw0s1lhluf7+ixl2OWOvVbvkZ KPyQH44IV05203I/l6hCyxWMJKPJI8YaJotTAo3WcvHKXtj1XbWvuZvdev+xbvQVbrbp D+fagCuAYMhg0Vm/W7WQUBFTeBHAXxF8zbbFuGjkFu+WN++Vl4F58eF4xAuV39A98qSp Yu494r3bE68c0TFft4T2KKbeNzfEv6U0jEB9hxs7rZnqQh4DwRWBfIZ+br/YTAua2eOj MsXLrG27GIptBdVzdTbZFJv8oEpgCBXKzPZ7R9kkXXp8iJ71cANA2tiOaBW80IToC5Bv WxNQ== 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=rr7mnGMGjh/O5JMo0e9mctqF3S6eAzihyba1zlVpto4=; b=fmmnc1PXynWfEsfaxqNoAZu3sZOYw2hZJyULB3wxcFjKHkJtDCop/HxVRsyp1e6tb/ 3VHY/pzenZWsSkaUw0nD0OJSTyOZuaVQk+DzsJ+1g0fzoHzeybDuMj14E9ydhyJqZoCJ n6ia3586Ds/mXSFHXfS5J9JhmLXcExSqMSfPlQSS19Re4Iw/jwBN8yOqZVoOCNgvd7GM rgj/+3u0J79xUJSsvMn3mjNV5UXjR8kGqSPlCdFejuvdGikv74BIuz2BP1ghgghNtM6r f8MvNyxaN7XdZtUk80bXxgiiczpUUxEK9sc6nJTxyh9dzI6zkun4tFRI6TuS28PK4kFu It2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=l5OxAdPv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb9si20343015edb.580.2020.12.28.08.24.13; Mon, 28 Dec 2020 08:24:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=l5OxAdPv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438510AbgL1QVq (ORCPT + 99 others); Mon, 28 Dec 2020 11:21:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:39816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732089AbgL1NMc (ORCPT ); Mon, 28 Dec 2020 08:12:32 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id EAC15208D5; Mon, 28 Dec 2020 13:12:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161137; bh=b3YkWgAGCc8tgJYY2DJD3faZH2Q/m3Lni073ZwViY7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l5OxAdPv2mObACiz1TWCBOgKY89P3gQ3qsD1YZQvao0jgUbfoTFq/YbmS/JuNRil6 2Ut2untCot+YpG39PT9Nq/0F9xi/XUrIHfXrA+xo4cwQeHjgTre5QlFG/jx2ZbmH+V fdiIIxV+vUI4u9YweFNxORNR0NasVFUaQWb0ABS8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Qinglang Miao , Serge Semin , Thomas Bogendoerfer , Sasha Levin Subject: [PATCH 4.14 114/242] mips: cdmm: fix use-after-free in mips_cdmm_bus_discover Date: Mon, 28 Dec 2020 13:48:39 +0100 Message-Id: <20201228124910.304411845@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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: Qinglang Miao [ Upstream commit f0e82242b16826077a2775eacfe201d803bb7a22 ] kfree(dev) has been called inside put_device so anther kfree would cause a use-after-free bug/ Fixes: 8286ae03308c ("MIPS: Add CDMM bus support") Reported-by: Hulk Robot Signed-off-by: Qinglang Miao Acked-by: Serge Semin Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin --- drivers/bus/mips_cdmm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/bus/mips_cdmm.c b/drivers/bus/mips_cdmm.c index 1b14256376d24..7c1da45be166e 100644 --- a/drivers/bus/mips_cdmm.c +++ b/drivers/bus/mips_cdmm.c @@ -544,10 +544,8 @@ static void mips_cdmm_bus_discover(struct mips_cdmm_bus *bus) dev_set_name(&dev->dev, "cdmm%u-%u", cpu, id); ++id; ret = device_register(&dev->dev); - if (ret) { + if (ret) put_device(&dev->dev); - kfree(dev); - } } } -- 2.27.0