Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4019527ybb; Mon, 13 Apr 2020 21:51:18 -0700 (PDT) X-Google-Smtp-Source: APiQypJeVpvGaA45gduoDCgWqGhWK2zsjPipag7GT/L4hIxW4P8oJ/XvvmPx3NTPVNlt1mucZeZQ X-Received: by 2002:a50:9e2a:: with SMTP id z39mr19550809ede.178.1586839878523; Mon, 13 Apr 2020 21:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586839878; cv=none; d=google.com; s=arc-20160816; b=hJ3CHVDrbj/D/JC1oWUwGIab7bfiTYDTkne/UB/wTGx86DZJuyWjLO0a7Wl+BD+nLN e9bToIm244+CMI/xf2lBIa0fSntBY9D4edPjmW4GK/CQFtaRTt23FKJu0Rx+8Y7KMVl3 XnBiDsEP2i7/pDEWkFnmA+wR6QCU1VpYYcM3wMBZTTDVMuF4mw/Va8m7Uf/cOIfK4yKE nLqdxp9eLy0+HnF4lPy+W+73e/4a/puaHcUWyeqd83dqbJd1DWBURLzJBVSVkynRtZuI /y+z3lUml1FErA8gDs2Z+iY9cyefq9VzJWhUXc54HfFQXk6AEYiZBjFAnz8DBFza4xrU Rl1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=yNfYaY6naeZuOmoeXUiErPz5ecFrDkrMrqxoSwLiYec=; b=ipVawm5573a0yuxCafV44RqHyTV+0Vv/ucQixCDEAuOx8PeTge40NZiyXxAIbmlvCB Shf3EsayPBRmy/utuyH/KcfDV84Wv2s1D4fCj3aV20aSsyupS8NNQMOR6AGT0fTFhK49 D529KZyD4m1WoiPjvkjx7NAQojEDrABRhWmgNtAb6fMVQiem5enk3tJ3IT6a56CYiW2x Rd9GautKLS7j90KUO2Lbrbt1ByMCR74gVrLGyFaBv1/uS4LonV74u1eEEMK6mwrxkI/A PqN5GGJJWkoJ3qM8mkggEjRdjsZ2mJ0ifnV2vH43MjXt63cSHlD+nF6jymczyCVGgCVe qVQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cc28si10490914edb.531.2020.04.13.21.50.52; Mon, 13 Apr 2020 21:51:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for 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; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729053AbgDMLfT (ORCPT + 99 others); Mon, 13 Apr 2020 07:35:19 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:58936 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728960AbgDMLfR (ORCPT ); Mon, 13 Apr 2020 07:35:17 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id E76FF3C5A2E54BFF94E0; Mon, 13 Apr 2020 19:35:11 +0800 (CST) Received: from huawei.com (10.175.102.37) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.487.0; Mon, 13 Apr 2020 19:35:03 +0800 From: Li Bin To: , , CC: , , , Subject: [PATCH] scsi: sg: add sg_remove_request in sg_common_write Date: Mon, 13 Apr 2020 19:29:21 +0800 Message-ID: <1586777361-17339-1-git-send-email-huawei.libin@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the dxfer_len is greater than 256M that the request is invalid, it should call sg_remove_request in sg_common_write. Fixes: f930c7043663 ("scsi: sg: only check for dxfer_len greater than 256M") Signed-off-by: Li Bin --- drivers/scsi/sg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 4e6af592..9c0ee19 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -793,8 +793,10 @@ static int get_sg_io_pack_id(int *pack_id, void __user *buf, size_t count) "sg_common_write: scsi opcode=0x%02x, cmd_size=%d\n", (int) cmnd[0], (int) hp->cmd_len)); - if (hp->dxfer_len >= SZ_256M) + if (hp->dxfer_len >= SZ_256M) { + sg_remove_request(sfp, srp); return -EINVAL; + } k = sg_start_req(srp, cmnd); if (k) { -- 1.7.12.4