Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2093229ybl; Thu, 30 Jan 2020 11:14:10 -0800 (PST) X-Google-Smtp-Source: APXvYqwRbDpQ+MfALFUeg0noS5z16XZJUrNNhpVQtqS5+ppPOm8ItprR23IA75mAlOC7hpS8sacf X-Received: by 2002:a05:6830:10d7:: with SMTP id z23mr4691290oto.114.1580411650703; Thu, 30 Jan 2020 11:14:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580411650; cv=none; d=google.com; s=arc-20160816; b=fx8ddstjDvzaPMHp/fXUoYU4zBK/AwSkKCPg4e4q+sBOHFAYGSY/4zkoqBLi5Vj/NX kFB1x57s7X6fxE86iA6gML/xi3vOTHhL3DcY9UpCnimHqmY4nJkcUriTFI9xVJxWZaYN IlAgK+WecHYxaE5ZJ/kqrnxGEpzagyoTAUzv03ejsuvmpqpe49JOVXjpKZGTXRKDowal 78xJC0kpSq+gZyqI83d/oOhpQLU3FVsbNYHyZ7kE+DxWW5PeLSGcdLnSvWYHy0Dd0tKY xSZSPb8grJbfqZV2dIzAIo96LzqMasx3YoQtSdNBDlVhujR6hfnmsbdoXC/Let6Vj9xH EJOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LDDB0FKAD3Ul/+Z7cjqIeIX/tadzrsARLStQF42pHDY=; b=ZYgKGcz7C/ZObaEslpayQ5Pw5MOZvGzgk9Fl0ZLjFpkOua3zU50aO3MqEBA6CAfiFg ImTIgdFXi3+Loj8V/PLiPW51w6TG+9RkBQdpTgyBVdazV/76MlLBEfcA8G9Q8URyE0rt AKTlRUsbVxEO+Rjb5keZ0oKweWm044rmqFip38QjtQGsLrGQb5IkrblqErw2TdMfBz2z HnXsNVONEcETsXF0z+F7BTv1PPlFEKLMSwnEoAR4U0fXYbyIuFzrkNnCO6BU04gJSx8B KrLXITITAhrP+FbDrJmpby2UQCNJDKb8U6gtV52L+om6XkVIaACYs6Ws4j5ZqMHP63QC BPrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vY7mCGWN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d83si2950787oib.166.2020.01.30.11.13.58; Thu, 30 Jan 2020 11:14:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vY7mCGWN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730142AbgA3SlV (ORCPT + 99 others); Thu, 30 Jan 2020 13:41:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:49228 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730133AbgA3SlS (ORCPT ); Thu, 30 Jan 2020 13:41:18 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9B2B9214DB; Thu, 30 Jan 2020 18:41:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409678; bh=LQYGm44o3kuZaSKrPBpL9FgbVJTuNAROgwlpse27PMA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vY7mCGWNuLHfbw46cXmbi2WPYQfunDVJ9mrLgwCY3NQw3O+sFS8GgWgVU77I1TZUK i+o3BjfcQmUEhoi3MfiN8SYCI69N/1CbO84oMLg/RaKCT155QuW2Xk3uMv7rO2xl7+ leBsJp5mzs2IkHfwP0ioKTBTyGd64hGi7w93/agQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+1d1597a5aa3679c65b9f@syzkaller.appspotmail.com, Prameela Rani Garnepudi , Amitkumar Karwar , Johan Hovold , Kalle Valo Subject: [PATCH 5.5 47/56] rsi: fix use-after-free on probe errors Date: Thu, 30 Jan 2020 19:39:04 +0100 Message-Id: <20200130183617.490446841@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183608.849023566@linuxfoundation.org> References: <20200130183608.849023566@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Hovold commit 92aafe77123ab478e5f5095878856ab0424910da upstream. The driver would fail to stop the command timer in most error paths, something which specifically could lead to the timer being freed while still active on I/O errors during probe. Fix this by making sure that each function starting the timer also stops it in all relevant error paths. Reported-by: syzbot+1d1597a5aa3679c65b9f@syzkaller.appspotmail.com Fixes: b78e91bcfb33 ("rsi: Add new firmware loading method") Cc: stable # 4.12 Cc: Prameela Rani Garnepudi Cc: Amitkumar Karwar Signed-off-by: Johan Hovold Signed-off-by: Kalle Valo Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/rsi/rsi_91x_hal.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/drivers/net/wireless/rsi/rsi_91x_hal.c +++ b/drivers/net/wireless/rsi/rsi_91x_hal.c @@ -622,6 +622,7 @@ static int bl_cmd(struct rsi_hw *adapter bl_start_cmd_timer(adapter, timeout); status = bl_write_cmd(adapter, cmd, exp_resp, ®out_val); if (status < 0) { + bl_stop_cmd_timer(adapter); rsi_dbg(ERR_ZONE, "%s: Command %s (%0x) writing failed..\n", __func__, str, cmd); @@ -737,10 +738,9 @@ static int ping_pong_write(struct rsi_hw } status = bl_cmd(adapter, cmd_req, cmd_resp, str); - if (status) { - bl_stop_cmd_timer(adapter); + if (status) return status; - } + return 0; } @@ -828,10 +828,9 @@ static int auto_fw_upgrade(struct rsi_hw status = bl_cmd(adapter, EOF_REACHED, FW_LOADING_SUCCESSFUL, "EOF_REACHED"); - if (status) { - bl_stop_cmd_timer(adapter); + if (status) return status; - } + rsi_dbg(INFO_ZONE, "FW loading is done and FW is running..\n"); return 0; } @@ -849,6 +848,7 @@ static int rsi_hal_prepare_fwload(struct ®out_val, RSI_COMMON_REG_SIZE); if (status < 0) { + bl_stop_cmd_timer(adapter); rsi_dbg(ERR_ZONE, "%s: REGOUT read failed\n", __func__); return status;