From patchwork Thu Mar 11 18:14:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Gilbert X-Patchwork-Id: 398065 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D972C433DB for ; Thu, 11 Mar 2021 18:15:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2B9164FBA for ; Thu, 11 Mar 2021 18:15:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229944AbhCKSOr (ORCPT ); Thu, 11 Mar 2021 13:14:47 -0500 Received: from smtp.infotech.no ([82.134.31.41]:51088 "EHLO smtp.infotech.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229789AbhCKSOg (ORCPT ); Thu, 11 Mar 2021 13:14:36 -0500 Received: from localhost (localhost [127.0.0.1]) by smtp.infotech.no (Postfix) with ESMTP id ACE4E20426D; Thu, 11 Mar 2021 19:14:29 +0100 (CET) X-Virus-Scanned: by amavisd-new-2.6.6 (20110518) (Debian) at infotech.no Received: from smtp.infotech.no ([127.0.0.1]) by localhost (smtp.infotech.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PrDAsbfe9Umx; Thu, 11 Mar 2021 19:14:28 +0100 (CET) Received: from xtwo70.bingwo.ca (host-45-58-219-4.dyn.295.ca [45.58.219.4]) by smtp.infotech.no (Postfix) with ESMTPA id 3B5EC204259; Thu, 11 Mar 2021 19:14:27 +0100 (CET) From: Douglas Gilbert To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com, hare@suse.de, colin.king@canonical.com Subject: [PATCH 1/4] sg: sg_rq_map_kern: fix uninitialized Date: Thu, 11 Mar 2021 13:14:20 -0500 Message-Id: <20210311181423.137646-2-dgilbert@interlog.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210311181423.137646-1-dgilbert@interlog.com> References: <20210311181423.137646-1-dgilbert@interlog.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Variable k should not be used in call to sg_mk_kern_bio(). Reported-by: Colin Ian King Signed-off-by: Douglas Gilbert --- drivers/scsi/sg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 2d4bbc1a1727..7d4a0fd9ee32 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -2987,7 +2987,7 @@ sg_rq_map_kern(struct sg_request *srp, struct request_queue *q, struct request * return 0; if (rw_ind == WRITE) op_flags = REQ_SYNC | REQ_IDLE; - bio = sg_mk_kern_bio(num_sgat - k); + bio = sg_mk_kern_bio(num_sgat); if (!bio) return -ENOMEM; bio->bi_opf = req_op(rqq) | op_flags; From patchwork Thu Mar 11 18:14:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Gilbert X-Patchwork-Id: 398064 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CAFCC433E6 for ; Thu, 11 Mar 2021 18:15:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BEBD64FE9 for ; Thu, 11 Mar 2021 18:15:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229469AbhCKSOr (ORCPT ); Thu, 11 Mar 2021 13:14:47 -0500 Received: from smtp.infotech.no ([82.134.31.41]:51100 "EHLO smtp.infotech.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229811AbhCKSOg (ORCPT ); Thu, 11 Mar 2021 13:14:36 -0500 Received: from localhost (localhost [127.0.0.1]) by smtp.infotech.no (Postfix) with ESMTP id 12D97204271; Thu, 11 Mar 2021 19:14:32 +0100 (CET) X-Virus-Scanned: by amavisd-new-2.6.6 (20110518) (Debian) at infotech.no Received: from smtp.infotech.no ([127.0.0.1]) by localhost (smtp.infotech.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NO4eeIsn8kxH; Thu, 11 Mar 2021 19:14:29 +0100 (CET) Received: from xtwo70.bingwo.ca (host-45-58-219-4.dyn.295.ca [45.58.219.4]) by smtp.infotech.no (Postfix) with ESMTPA id 7A94B204269; Thu, 11 Mar 2021 19:14:28 +0100 (CET) From: Douglas Gilbert To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com, hare@suse.de, colin.king@canonical.com Subject: [PATCH 2/4] sg: sg_remove_sfp_usercontext: remove NULL check Date: Thu, 11 Mar 2021 13:14:21 -0500 Message-Id: <20210311181423.137646-3-dgilbert@interlog.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210311181423.137646-1-dgilbert@interlog.com> References: <20210311181423.137646-1-dgilbert@interlog.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The NULL check on sdp is useless as it has already been de-referenced. sg_fd object without valid parent pointer (sdp) should never occur. Reported-by: Colin Ian King Signed-off-by: Douglas Gilbert --- drivers/scsi/sg.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 7d4a0fd9ee32..77fec70b7c2f 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -3918,10 +3918,8 @@ sg_remove_sfp_usercontext(struct work_struct *work) o_count, sfp); kfree(sfp); - if (sdp) { - scsi_device_put(sdp->device); - kref_put(&sdp->d_ref, sg_device_destroy); - } + scsi_device_put(sdp->device); + kref_put(&sdp->d_ref, sg_device_destroy); module_put(THIS_MODULE); } From patchwork Thu Mar 11 18:14:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Gilbert X-Patchwork-Id: 398063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B47EC433DB for ; Thu, 11 Mar 2021 18:15:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ECF5964FD6 for ; Thu, 11 Mar 2021 18:15:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229972AbhCKSOr (ORCPT ); Thu, 11 Mar 2021 13:14:47 -0500 Received: from smtp.infotech.no ([82.134.31.41]:51124 "EHLO smtp.infotech.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229871AbhCKSOg (ORCPT ); Thu, 11 Mar 2021 13:14:36 -0500 Received: from localhost (localhost [127.0.0.1]) by smtp.infotech.no (Postfix) with ESMTP id 3103D204259; Thu, 11 Mar 2021 19:14:34 +0100 (CET) X-Virus-Scanned: by amavisd-new-2.6.6 (20110518) (Debian) at infotech.no Received: from smtp.infotech.no ([127.0.0.1]) by localhost (smtp.infotech.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AzFt619Rxqf3; Thu, 11 Mar 2021 19:14:32 +0100 (CET) Received: from xtwo70.bingwo.ca (host-45-58-219-4.dyn.295.ca [45.58.219.4]) by smtp.infotech.no (Postfix) with ESMTPA id 037C120426C; Thu, 11 Mar 2021 19:14:30 +0100 (CET) From: Douglas Gilbert To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com, hare@suse.de, colin.king@canonical.com Subject: [PATCH 4/4] sg: sg_common_write: remove debug remnant Date: Thu, 11 Mar 2021 13:14:23 -0500 Message-Id: <20210311181423.137646-5-dgilbert@interlog.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210311181423.137646-1-dgilbert@interlog.com> References: <20210311181423.137646-1-dgilbert@interlog.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The removed check was added as part of scattergun debugging to find a problem that was fixed elsewhere. The associated SG_LOG message has never been seen in testing. Signed-off-by: Douglas Gilbert --- drivers/scsi/sg.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index b6e06e039d5b..9593f8eaf56c 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1120,11 +1120,6 @@ sg_common_write(struct sg_comm_wr_t *cwrp) res = -EIDRM; /* this failure unexpected but observed */ goto err_out; } - if (xa_get_mark(&fp->srp_arr, srp->rq_idx, SG_XA_RQ_FREE)) { - SG_LOG(1, fp, "%s: ahhh, request erased!!!\n", __func__); - res = -ENODEV; - goto err_out; - } srp->rq->timeout = cwrp->timeout; sg_execute_cmd(fp, srp); return srp;