Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1908477imm; Tue, 22 May 2018 11:15:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrU6JuQgc5V7k7wRK3QVdm6QSBprLY0b36/aSgStb5lrk/0gtLQxI2KMYaPHaGrGfqIFXBj X-Received: by 2002:a65:6510:: with SMTP id x16-v6mr20289468pgv.204.1527012954006; Tue, 22 May 2018 11:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527012953; cv=none; d=google.com; s=arc-20160816; b=lh7JJMp88JoHnpachD5Dcqs0AarpStIdEyRpuTsXFLmsQbd/a5LwLok5XT2X6pocC/ ehy6Q1rilnOKMVYAiCBCqW8HGkJctKIyIRwcZ/9viwWy8WFjZMDoJWxuYcSEWRD391Y0 hp/2T+E7G+5sRQRDVbpYPHMEr1rGGxizQV77oGnKatbHxrJ/2Q3//c9FCbwasWXbRbap AOEVSOAyE7Q4ypUN1MiDcCIsomevjhxnuFnIa0st5e3nvpR0zHMULznyA9FnZJQ+dN7x xu1wMLsUslgPb5832DXx2ou5ccdqXVfEU0RC/N/g2um8LzCnFC0E47eE8f7pqs6H0jjK KgqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=4Ai0gY4+6TnBSrMLJF3jPLTmSm9JUKjuuuAf5/TK6is=; b=eZsQ+1ioK6WmCAvgdqbntVrMDIr6AUtF6PfKBpf38/WeKzu2Pm39rdIij3U6CbCI4q GbvzLb5i+6KBCOICmmwuxBxuBUgwSsVgjUe7HwlDwQemeTNeVOHzey0ZE0xU1IUdLnOg 5Zq0boT4kupe+5rzlJg0V9N5d6nZr2p6B84F/UolDVDf3Sc7u6ZFxnIB5jD6eCwD4PKz YgroZPf3d9eYKMPNvmfbMLmT9fA2oPlATq5fIUL8n1NIfaskSynBSM2tgzOY8J6V+CDX 3t8gbR0gJwv7Pr2tMQFYSt/8sjAr9NShaBlGkelRRzF1owSCcSnkFrZT3UKEGztov1o1 xDpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mUzx5DzU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t23-v6si16451958ply.237.2018.05.22.11.15.39; Tue, 22 May 2018 11:15:53 -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=@chromium.org header.s=google header.b=mUzx5DzU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751673AbeEVSP1 (ORCPT + 99 others); Tue, 22 May 2018 14:15:27 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:37358 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751369AbeEVSPV (ORCPT ); Tue, 22 May 2018 14:15:21 -0400 Received: by mail-pf0-f196.google.com with SMTP id e9-v6so9173485pfi.4 for ; Tue, 22 May 2018 11:15:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4Ai0gY4+6TnBSrMLJF3jPLTmSm9JUKjuuuAf5/TK6is=; b=mUzx5DzUEZxo9R6teEFepSlM/8VnDwj2rJuCUC1r0M1VNpycQchf0J3YxPYs/SAOQT MxgW97goTcA7TVBiomltpoNVeW3v6sbkmYK3wWfxv+ny2ezeIAJVQCg+67zIs3UQV9de VBTq7bUu5ZoXNACmmrXwoDRBYzvN4Wm5ojt+U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4Ai0gY4+6TnBSrMLJF3jPLTmSm9JUKjuuuAf5/TK6is=; b=b3xHZoIl1yccfvej1WhtmBjOMn7fpmY82UllQXffP0ZuXeuWlw5vnxpk3bBo5MrDQ8 UJnEo0PuqKwGDSH6aJMduRAndITIvVr42HfBjqJD2oG9udDpw+JODu0jgWZmj1Po6kP5 Y6i1mErdLEXlTvIxb5pDvC0eGnN06/oQF3ndzIfBx4W8LmZOn8lxq7euoyIqOMi4J7tD CbOPAc79hkqbSGzOvO3rX8s4QXJIwc0LOqKjwmxV5vN21MWPDPFlrzNVn20/+akwENCf tEQt2JvFERvyWA0uz0YiYgBSoyWtOcYK5wkooLkYgMtoFbcmgJFD3AiGD/d1V7OWVROM Ic7Q== X-Gm-Message-State: ALKqPwf988GmYoLJteA2vzEGKZG1ac7Vo1PFPx9nyfBPjRxY+4Bgi444 8vrXl/R3qSXS46XQHFsUFi4P9g== X-Received: by 2002:a62:6c87:: with SMTP id h129-v6mr25059651pfc.179.1527012921243; Tue, 22 May 2018 11:15:21 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id v23-v6sm28611663pfe.166.2018.05.22.11.15.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 May 2018 11:15:18 -0700 (PDT) From: Kees Cook To: Jens Axboe Cc: Kees Cook , "Martin K. Petersen" , James Bottomley , Tejun Heo , Borislav Petkov , "David S. Miller" , "Manoj N. Kumar" , "Matthew R. Ochs" , Uma Krishnan , linux-block@vger.kernel.org, linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] scsi: cxlflash: Drop unused sense buffers Date: Tue, 22 May 2018 11:15:08 -0700 Message-Id: <20180522181512.39316-3-keescook@chromium.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180522181512.39316-1-keescook@chromium.org> References: <20180522181512.39316-1-keescook@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This removes the unused sense buffer in read_cap16() and write_same16(). Signed-off-by: Kees Cook --- drivers/scsi/cxlflash/superpipe.c | 8 ++------ drivers/scsi/cxlflash/vlun.c | 7 ++----- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c index 2fe79df5c73c..59b9f2023748 100644 --- a/drivers/scsi/cxlflash/superpipe.c +++ b/drivers/scsi/cxlflash/superpipe.c @@ -324,7 +324,6 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli) struct scsi_sense_hdr sshdr; u8 *cmd_buf = NULL; u8 *scsi_cmd = NULL; - u8 *sense_buf = NULL; int rc = 0; int result = 0; int retry_cnt = 0; @@ -333,8 +332,7 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli) retry: cmd_buf = kzalloc(CMD_BUFSIZE, GFP_KERNEL); scsi_cmd = kzalloc(MAX_COMMAND_SIZE, GFP_KERNEL); - sense_buf = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); - if (unlikely(!cmd_buf || !scsi_cmd || !sense_buf)) { + if (unlikely(!cmd_buf || !scsi_cmd)) { rc = -ENOMEM; goto out; } @@ -349,7 +347,7 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli) /* Drop the ioctl read semahpore across lengthy call */ up_read(&cfg->ioctl_rwsem); result = scsi_execute(sdev, scsi_cmd, DMA_FROM_DEVICE, cmd_buf, - CMD_BUFSIZE, sense_buf, &sshdr, to, CMD_RETRIES, + CMD_BUFSIZE, NULL, &sshdr, to, CMD_RETRIES, 0, 0, NULL); down_read(&cfg->ioctl_rwsem); rc = check_state(cfg); @@ -380,7 +378,6 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli) if (retry_cnt++ < 1) { kfree(cmd_buf); kfree(scsi_cmd); - kfree(sense_buf); goto retry; } } @@ -411,7 +408,6 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli) out: kfree(cmd_buf); kfree(scsi_cmd); - kfree(sense_buf); dev_dbg(dev, "%s: maxlba=%lld blklen=%d rc=%d\n", __func__, gli->max_lba, gli->blk_len, rc); diff --git a/drivers/scsi/cxlflash/vlun.c b/drivers/scsi/cxlflash/vlun.c index 5deef57a7834..e7e9b2f2ad21 100644 --- a/drivers/scsi/cxlflash/vlun.c +++ b/drivers/scsi/cxlflash/vlun.c @@ -425,7 +425,6 @@ static int write_same16(struct scsi_device *sdev, { u8 *cmd_buf = NULL; u8 *scsi_cmd = NULL; - u8 *sense_buf = NULL; int rc = 0; int result = 0; u64 offset = lba; @@ -439,8 +438,7 @@ static int write_same16(struct scsi_device *sdev, cmd_buf = kzalloc(CMD_BUFSIZE, GFP_KERNEL); scsi_cmd = kzalloc(MAX_COMMAND_SIZE, GFP_KERNEL); - sense_buf = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); - if (unlikely(!cmd_buf || !scsi_cmd || !sense_buf)) { + if (unlikely(!cmd_buf || !scsi_cmd)) { rc = -ENOMEM; goto out; } @@ -456,7 +454,7 @@ static int write_same16(struct scsi_device *sdev, /* Drop the ioctl read semahpore across lengthy call */ up_read(&cfg->ioctl_rwsem); result = scsi_execute(sdev, scsi_cmd, DMA_TO_DEVICE, cmd_buf, - CMD_BUFSIZE, sense_buf, NULL, to, + CMD_BUFSIZE, NULL, NULL, to, CMD_RETRIES, 0, 0, NULL); down_read(&cfg->ioctl_rwsem); rc = check_state(cfg); @@ -481,7 +479,6 @@ static int write_same16(struct scsi_device *sdev, out: kfree(cmd_buf); kfree(scsi_cmd); - kfree(sense_buf); dev_dbg(dev, "%s: returning rc=%d\n", __func__, rc); return rc; } -- 2.17.0