Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9036747pxu; Mon, 28 Dec 2020 05:05:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZYKFu+EyZiJOFpeR8QSppxpvjphnb/MZQUqsYeH4Lzeo6T01STWYDjzBKxvixemvKct8W X-Received: by 2002:a50:e80c:: with SMTP id e12mr40967358edn.288.1609160727283; Mon, 28 Dec 2020 05:05:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609160727; cv=none; d=google.com; s=arc-20160816; b=sa4gfHCpU2z/4Eqsh/Wu/J3H2Jz30YW1SXGNqZiMdLh0rAhGCUMcXerA+foUFjB6VJ bR6vr3vqxi6G9TEiMoANqlsnzduJ8jpjSOptwh5UjRi+DEUm+grQ5V8KAu7blWZ07XHS DDqFZMoNj3LDZbuO4MXfYPYCGWQTf/NFJufO62k80qjH44kqUXlfH32FhUe4p+unowV2 0NOXRGG4ArbeEJPysbGZL5ar+19UaGDhKluad+mnLcmlrEhu8xIPrljlIwmEhT9luhZu 34rx18fOTO7DKDSP6kyFCg7fNTFJL8Iu7vhY4PCJsq3ojqD7WhsHR7p5CEl/jCi6hHrR 5mZA== 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=Fb2AnMMUltM37BQienm+4ZqhtTOUmxKpnSojNoYqYUeJ9aLY6r0ulZmC1VOwsx58cC v0/gFJZsWOse7JYCX3nMSaTJCQeVq4CNe+qjUDPlAyMwV13mlsES68UC0Wgf8kw7kos9 OlS9TEEQI6kdyOmsdOev8eqlcrQEsLlsUyJBww/lulYxgLJdfCiACztXR1Q/YikdFS0j ZnNaqqI0wvMPfuYaZZYtAaYYZOir/2yLQNHc7PLZ2RFjmbNtYdok95ioQOWw4d7b2Y0P qSP6gf45Y7pF/GFM1I7IsAdPS1xQDJ3aan27z+zEwP1rCaUfDLLpkPZOiqNvl5IK2Wsq 3pWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="em/a6it6"; 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 y14si20709696edm.451.2020.12.28.05.05.03; Mon, 28 Dec 2020 05:05:27 -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="em/a6it6"; 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 S1730092AbgL1NCf (ORCPT + 99 others); Mon, 28 Dec 2020 08:02:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:58042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730074AbgL1NCd (ORCPT ); Mon, 28 Dec 2020 08:02:33 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A459B22573; Mon, 28 Dec 2020 13:02:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160538; bh=b3YkWgAGCc8tgJYY2DJD3faZH2Q/m3Lni073ZwViY7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=em/a6it6aNuHXOBPurEm01WqutzaS37FpgedSUG5L9CcvN3oG2SUscUb+fCCimwhY b4FS6AnqhBCSe0pDj37BZUuOx7/8Oq20+4NZU4wQfsPRdYMtWYafQQn2sr9djBYG4V ZjtUmvDfIuzym8u2GE/DndM1eEcAu9oiaXpDs8QY= 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.9 083/175] mips: cdmm: fix use-after-free in mips_cdmm_bus_discover Date: Mon, 28 Dec 2020 13:48:56 +0100 Message-Id: <20201228124857.262943666@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@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