Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2253600ybd; Mon, 24 Jun 2019 03:22:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMLCUB+luzj7QgL+c7fZG61mhAM41hRZiB2+PY9CVUffRmGOPsbLGP768aiAllDGQ2AmlQ X-Received: by 2002:a17:902:e30d:: with SMTP id cg13mr34108835plb.173.1561371723658; Mon, 24 Jun 2019 03:22:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561371723; cv=none; d=google.com; s=arc-20160816; b=09KNVJsZ5DA0FkDm442M9EIQoXh7Z5tXplnVK9bqJARdwCcbXcywgrs59QeFn0auz7 OzshctoRA/QMiaWWiyWmgMatdCDGkux3EqY7cUIm32ngIx0LBii6kagRIYgpqQdINf3G Xose7eE/juoVU55f3U0krfgawLxRoIMPwtlw6iCUOhHfcVd5rr5fpMKsHtVqtXO47e33 ybGktag4fXjmhzJyJKcRBLmhyPT7EMg9zyfIHnYXpuQK2oPbW1UhigpqjH27W0aJVmcn 9O882BLiapBN3a1L8x6YjoRfvTq/jFGiBnDwprchnvRs3ZhtrjUGYCLhdG6gDG+EfZOr QSXg== 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=zOIGZ5RSaQpygYTADLgZ7aJvqTwigsL2fqrfy5bdvvg=; b=0zz6mCQoP9TEFzru8Bl+7l/3HNa8tPUr1rGdVuWvq62jTsNZywc4kf/PBPyntr7JTN BaVT5Qf7hYHAkr1kKZGWHmo+uOqDlw3Tff2oSD9D/0dG0NZmYREvFcEMlTB6HVfUKksp xLEvrHHI3AJzHLHjMsQH54qPPUUYVWsFALYfl0jlTqKKJcuD/wn+BgCVsUspRqCTnZa+ Ma9trzxjrFa0TAZgfdi3N7JZd5xLbYW4Kv9gJkV/C7gXNgptslvFjyHYWoEtMeqxKBAC 7SicS/Hjsmo9IcZVNrE49MwMNWe84xtRztsvPgVHDQIuRBi2jPS8LuqWLkCQo09dlb3C T2hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VCyJkBoO; 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 h15si4991383plr.23.2019.06.24.03.21.47; Mon, 24 Jun 2019 03:22:03 -0700 (PDT) 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=VCyJkBoO; 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 S1729708AbfFXKVg (ORCPT + 99 others); Mon, 24 Jun 2019 06:21:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:57240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727525AbfFXKVe (ORCPT ); Mon, 24 Jun 2019 06:21:34 -0400 Received: from localhost (f4.8f.5177.ip4.static.sl-reverse.com [119.81.143.244]) (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 868DB2089F; Mon, 24 Jun 2019 10:21:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561371694; bh=Kw1mpABG4CIcAUpoJ0aMROBIUYxIWsrlD7TXc+yhPsk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VCyJkBoOJMF2CB2AJtK2cJge6rjohZuRT61CPFgtGPnbNPHGfH/fk2RDyvzYcoQiR rS00zCsDZYDRNgfc+GRhj3XxoPZaQFBtQ7rdON9uu7nnP+cbjDffgyYKfKbU6I9H/o JBEMfxaYgczUlVJoOAuXq26iCXmhCzVjCJQU8SF8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Avri Altman , Alim Akhtar , Bean Huo , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.1 077/121] scsi: ufs: Check that space was properly alloced in copy_query_response Date: Mon, 24 Jun 2019 17:56:49 +0800 Message-Id: <20190624092324.813898254@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190624092320.652599624@linuxfoundation.org> References: <20190624092320.652599624@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 [ Upstream commit 1c90836f70f9a8ef7b7ad9e1fdd8961903e6ced6 ] struct ufs_dev_cmd is the main container that supports device management commands. In the case of a read descriptor request, we assume that the proper space was allocated in dev_cmd to hold the returning descriptor. This is no longer true, as there are flows that doesn't use dev_cmd for device management requests, and was wrong in the first place. Fixes: d44a5f98bb49 (ufs: query descriptor API) Signed-off-by: Avri Altman Reviewed-by: Alim Akhtar Acked-by: Bean Huo Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/ufs/ufshcd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 5ba49c8cd2a3..dbd1f8c253bf 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1917,7 +1917,8 @@ int ufshcd_copy_query_response(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) memcpy(&query_res->upiu_res, &lrbp->ucd_rsp_ptr->qr, QUERY_OSF_SIZE); /* Get the descriptor */ - if (lrbp->ucd_rsp_ptr->qr.opcode == UPIU_QUERY_OPCODE_READ_DESC) { + if (hba->dev_cmd.query.descriptor && + lrbp->ucd_rsp_ptr->qr.opcode == UPIU_QUERY_OPCODE_READ_DESC) { u8 *descp = (u8 *)lrbp->ucd_rsp_ptr + GENERAL_UPIU_REQUEST_SIZE; u16 resp_len; -- 2.20.1