Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2607833pxu; Mon, 14 Dec 2020 06:46:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlbUOzCY33Kg5MQ2ua3zVe1xUrC+zIUXxentD8/h3Fr/TMdc/PW1NNAyvQP1kskrTvzOEP X-Received: by 2002:a17:906:a011:: with SMTP id p17mr22410004ejy.30.1607957171289; Mon, 14 Dec 2020 06:46:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607957171; cv=none; d=google.com; s=arc-20160816; b=Vljn6KnOxnjx32mLa3iHCr0b7krF83r1PoiwwaR9DC+Y9kIle3jO/kgJ9sZQ+gIN1R L+xGRkXt4raX4VDnlplwRlsPVif0fx6G4q9c8rrMIAZZHMlzSzYa78qnoHfHfwelarJL x/fweHJ+K0X7a6aocnH+MSGw6vLh72Qa2+U5ARqTaHBgU6oAyVt1zQkj9g1jLorfFUWf WfUy+SSYrqg8U4d8AN2dX6kVEXlZbqZ1Vga29h1mJ8Bfgmhjf7j338pm7In2hCunmVfl MCLR4vP9tuGxxHIAdUa67bphayFrfu3rcexL5omcIoXp/xRUE7jifu6du5gTEJxMfDwx iaCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=6zvqgCwWDc0LxzwMBvEpsmX5L8GftQWwiFbcTDv2mZ8=; b=QGK2Cegr8fMi0/6KIE2wZeO7gXLFT3P9w/6h2cDTJvp6y6ca144iWcvZ1Z8wTa0byz cEofj0lXKcSYx8OlyzpToMdqJxsa7HuxPHCNldBzjGwgzzT7xbQGYajAz7pTxLEtMPSS CNYVr0MbNsa8TgbdY/BzC5LhDkKQiyq40cUbfesCkz2Ye9JOPCVfj8ANXDMj3Bh6is27 M7+IJQ2mY1PC1LKN58J0JlmjMq8t/KdT/HCAxpFGiCReVlBxtFXVmOJAE1PONfTizFtu W8wkG9HyJsdJD1bfnYUUrBo6n2SUtndT5PekRx/AS4vydQHPBant9OAI4JskrJReKxdG 4/Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=eoYoeiXC; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d7si9429667ejk.78.2020.12.14.06.45.47; Mon, 14 Dec 2020 06:46:11 -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=@oracle.com header.s=corp-2020-01-29 header.b=eoYoeiXC; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437954AbgLNMAR (ORCPT + 99 others); Mon, 14 Dec 2020 07:00:17 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:60402 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731339AbgLNMAQ (ORCPT ); Mon, 14 Dec 2020 07:00:16 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0BEBoebG179710; Mon, 14 Dec 2020 11:59:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2020-01-29; bh=6zvqgCwWDc0LxzwMBvEpsmX5L8GftQWwiFbcTDv2mZ8=; b=eoYoeiXCFyQClBKAZ8/eCFpOdKPkUSBD5uF7nCVL+UcypRFX8GtTfP+93WA5py+sOTuC 7T+gUa/g+F0ls8x9b9rYVdyfEeJIsn+IkX9X1OgWm5sHbMmEGcjQZu6BW93eeUsDLH3y Qc5DDfVXNFLT0ntBbJAi8nMsj87mlHfPfRweDodPEJPSAuZi2yFPIP3l775SZtCjZUui bRCxDKdDB6RFreUVBmDDjMBgdjkI3wWwl01e2WmGYFg9VOo6ssoJp0GGiIUAc/2dM5nN ddvOrh0MnNDJic0FmUcv8F46na/57ab2b7O2BlcWwhvwRhbrcbON0Rr/HJJturIldJNU tQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 35cn9r4svn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 14 Dec 2020 11:59:21 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0BEBsmSp022063; Mon, 14 Dec 2020 11:59:20 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 35e6entcwr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 14 Dec 2020 11:59:20 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0BEBxIjd026571; Mon, 14 Dec 2020 11:59:18 GMT Received: from mwanda (/102.36.221.92) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 14 Dec 2020 03:59:17 -0800 Date: Mon, 14 Dec 2020 14:59:10 +0300 From: Dan Carpenter To: Lee Jones Cc: Mark Brown , Samuel Ortiz , patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] mfd: wm831x-auxadc: Prevent use after free in wm831x_auxadc_read_irq() Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9834 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012140085 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9834 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 impostorscore=0 lowpriorityscore=0 clxscore=1011 spamscore=0 malwarescore=0 priorityscore=1501 phishscore=0 mlxscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012140084 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 8a7cc0f86958..65b98f3fbd92 100644 --- a/drivers/mfd/wm831x-auxadc.c +++ b/drivers/mfd/wm831x-auxadc.c @@ -93,11 +93,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.29.2