Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3543244pxb; Mon, 1 Mar 2021 12:51:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyIXTqIsJVB/szDfzLvsNirRe6ag0xupEAB42wKnqI5j65YIZsD1NRAHgDTRi4KuD8dzMyR X-Received: by 2002:a17:907:3e06:: with SMTP id hp6mr17742969ejc.254.1614631875496; Mon, 01 Mar 2021 12:51:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614631875; cv=none; d=google.com; s=arc-20160816; b=d8tSq4eSC1zTxxRCk5c59oWcpTQwLsN1AByEx54y7kA30OM/VEdzlfEfE10NbF0XA1 5JSsniDpRP7CrulAnwamsGzBOZO8QQxRXloPXv8ItZx21841rICdOazzjRZ29+1yw0ez K2Xd3LP1cQvGIoMC7bMi8/ZzUo+TwzFwmV07md1Mgs9/Hvp7IIRCwVGDtJbRuaz3LMx6 0uRDScVcauV4vvD2w/pt+h/dB9kNRa7kgnWLF7VciaGUymsD8DbkTen40eArxi9Iv3Wd dL9cLPRi5MxZ48+YL/RelwH43a6aiDXBIHqTN0cN/+5z3kLkh8NiTLhDXHedk1ifDwsU lngg== 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=yZojf03aW5BaTVSrHz6trngNe+FQ6cpJuDaXR6651ko=; b=Sq93qri0rBPUKTXDYv39YwQhtLD6hWqybbyLxnraq4b5bSZ4XRM5+8FJWTxv0g+Ydl Lzgyg+3s/6Qt5501qD3ECYfXaF7B/oRi9CzyBivhPuDyb8PSM2xzv7/VlGTERgM+uF6h 6NAib5mDwYuRiHyTVTnlh4ullVKkL+N3jl2EHmMNIYZqX3buq8fW1QMMZuct1bpkeNoM VrRIGuSc9wfVqK7iGm0UDoY17hMvlcpOrcGizFGT67Wty6wk2YsPZLNObobx4+aih9b4 ezof/Uy7JzlVNbjW1/MpJyWiaV/pfJUhrQte/NsgUaWOPuKhqYEs+Y4ENaEB3CawXF8w mr+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ty1daRHk; 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 c16si11384304edu.304.2021.03.01.12.50.52; Mon, 01 Mar 2021 12:51:15 -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=Ty1daRHk; 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 S243689AbhCAUrx (ORCPT + 99 others); Mon, 1 Mar 2021 15:47:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:35318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236688AbhCARIk (ORCPT ); Mon, 1 Mar 2021 12:08:40 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 249F265017; Mon, 1 Mar 2021 16:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614616931; bh=dZDuYGpAecR4SZKdufLNZDrBQ7R3UW6Uz7HS7zGTTVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ty1daRHkNnjgFX2uQzl3OvILK9UKGOkMy3G3Bs2yRG2taQunOnsfRXB/2WsNoNjHl ZemF9RXPKoZRtnr4trOMBKmZJF+TI3ScYBNKHdtBWuyih2cEEI3WzIqFthcKxd0YZ+ HaWsYsDft1bgGT8FDkiW7HZv7hWH5UPDFzXGh+eY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Charles Keepax , Lee Jones , Sasha Levin Subject: [PATCH 4.19 144/247] mfd: wm831x-auxadc: Prevent use after free in wm831x_auxadc_read_irq() Date: Mon, 1 Mar 2021 17:12:44 +0100 Message-Id: <20210301161038.719566392@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@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: Dan Carpenter [ Upstream commit 26783d74cc6a440ee3ef9836a008a697981013d0 ] The "req" struct is always added to the "wm831x->auxadc_pending" list, but it's only removed from the list on the success path. If a failure occurs then the "req" struct is freed but it's still on the list, leading to a use after free. Fixes: 78bb3688ea18 ("mfd: Support multiple active WM831x AUXADC conversions") Signed-off-by: Dan Carpenter Acked-by: Charles Keepax Signed-off-by: Lee Jones Signed-off-by: Sasha Levin --- drivers/mfd/wm831x-auxadc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/mfd/wm831x-auxadc.c b/drivers/mfd/wm831x-auxadc.c index fd789d2eb0f52..9f7ae1e1ebcd6 100644 --- a/drivers/mfd/wm831x-auxadc.c +++ b/drivers/mfd/wm831x-auxadc.c @@ -98,11 +98,10 @@ static int wm831x_auxadc_read_irq(struct wm831x *wm831x, wait_for_completion_timeout(&req->done, msecs_to_jiffies(500)); mutex_lock(&wm831x->auxadc_lock); - - list_del(&req->list); ret = req->val; out: + list_del(&req->list); mutex_unlock(&wm831x->auxadc_lock); kfree(req); -- 2.27.0