From patchwork Tue Jul 31 19:51:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10551247 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E6A91822 for ; Tue, 31 Jul 2018 19:52:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C9502B49D for ; Tue, 31 Jul 2018 19:52:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 108EA2B52A; Tue, 31 Jul 2018 19:52:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 976942B4EE for ; Tue, 31 Jul 2018 19:52:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732537AbeGaVeC (ORCPT ); Tue, 31 Jul 2018 17:34:02 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43835 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732535AbeGaVeB (ORCPT ); Tue, 31 Jul 2018 17:34:01 -0400 Received: by mail-pf1-f194.google.com with SMTP id j26-v6so6597564pfi.10 for ; Tue, 31 Jul 2018 12:52:08 -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=Q7jGiY6bcjknel3f67YCdBy100vkB2E9u4fhQCP3suo=; b=DPQ1RajVjK4/NlRNn5tSUQrg/ESfpJ6VOgG6EOxtgSuy9EQeqdPkaEZ8E936/NJN8g uhJWOLRBzudVudKXGoXPVJU4yt4W21uWSH6J893lcGpHJrfSDcajTGpAH6bw/jXX1Fck g+jTfuPTfzlXSh3aDcXBbXs/owtwdg+QUyP70= 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=Q7jGiY6bcjknel3f67YCdBy100vkB2E9u4fhQCP3suo=; b=Okk+jea1rrIgIKgnLWae6qTI3MynjhcjppL1LrU8+0KYngXe8TqRng5bPcN2nbYNFs dFqLGxWS0640fzcBDB5REob60ZfsrzumqwvKqBBamebKfsZ/k2/CiqbU6RpbhzHZHv9u IKnyXev4o6TfZ1lbBKf7phmwK2S3o1tC3DQQ3kdCpXzHFdvI8Gk8TvyUnwIUJel11dvB Cs3unzwQe3PVQ7coSHezVRWKFjaXPDpCZQMGkYFNEAMQJIK8uFck6uQcfAGgEIfDE0zh 1EkFmKtI9OYSPyGgqCDtgP+HFMXgODweiuqyXyde5q0qVe8zm1ZypkMawv5KqsFrPcNn jq0Q== X-Gm-Message-State: AOUpUlGsAhcSwFiMzLR/7QViUKCt3fGDe3nG/u7FQvJfRMa2I4VcvwiT I2y2Lb+zLDHh2IGTsG6IHwNkCw== X-Google-Smtp-Source: AAOMgpd1W49IHWu8Xdm4kYVr99i5ZDoLZddE858jTmxXjOs5MwA1txFGid898+FLN6f7vXdMAu7xLw== X-Received: by 2002:a63:ab4c:: with SMTP id k12-v6mr21381868pgp.386.1533066727678; Tue, 31 Jul 2018 12:52:07 -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 x15-v6sm23735181pgc.46.2018.07.31.12.52.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Jul 2018 12:52:02 -0700 (PDT) From: Kees Cook To: Jens Axboe Cc: Kees Cook , Christoph Hellwig , "Martin K. Petersen" , "James E.J. Bottomley" , Tejun Heo , Borislav Petkov , "David S. Miller" , "Manoj N. Kumar" , "Matthew R. Ochs" , Uma Krishnan , "Nicholas A. Bellinger" , Thomas Gleixner , Philippe Ombredanne , Stephen Boyd , Cyrille Pitchen , Juergen Gross , Viresh Kumar , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Sagar Dharia , Randy Dunlap , Vinod Koul , David Kershner , linux-block@vger.kernel.org, linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/9] scsi: cxlflash: Drop unused sense buffers Date: Tue, 31 Jul 2018 12:51:47 -0700 Message-Id: <20180731195155.46664-3-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180731195155.46664-1-keescook@chromium.org> References: <20180731195155.46664-1-keescook@chromium.org> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This removes the unused sense buffer in read_cap16() and write_same16(). Signed-off-by: Kees Cook Reviewed-by: Christoph Hellwig Acked-by: Matthew R. Ochs --- 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; }