From patchwork Fri Jun 14 08:36:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Young Xiao <92siuyang@gmail.com> X-Patchwork-Id: 10994697 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 E24C91395 for ; Fri, 14 Jun 2019 08:35:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0D3D2228E for ; Fri, 14 Jun 2019 08:35:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFFB122B26; Fri, 14 Jun 2019 08:35:33 +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,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 71AEA2228E for ; Fri, 14 Jun 2019 08:35:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726567AbfFNIf2 (ORCPT ); Fri, 14 Jun 2019 04:35:28 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:34010 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725907AbfFNIf2 (ORCPT ); Fri, 14 Jun 2019 04:35:28 -0400 Received: by mail-pl1-f195.google.com with SMTP id i2so728517plt.1; Fri, 14 Jun 2019 01:35:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ZpRAiGHrxAIp1S+RPmqFGpGzlBqUdjPBsoJh2VxfpuI=; b=E9jS9HpuVjphXVxURvMgQuFhZQ2njfiNbye4l8eNwERdDTyQ//sQxXLUHnkGal6Ha5 2cUCQ4kwQa4Igxa9ZrGG1dkPFGhN0DPBzE34S7Uup7ibzyahrFSgG37n6EzJnNW989G5 EcYS7Lg0TNwe8UWbpZx1st2mvltLOBg/iPAv6MFv2mocK0/4QQJhQrRkLMF3JAzt33AT eedmXS6/f9aNWoUj1cp59m0r/xbuSHlROtrXS6E/U2d7kx8stFKbxv9zl+XeSDZ6Afg3 jKe8rW6CfUNhnZdjkV6Bqqru8xV69ajylMWI/icXrl/BWyBKFGrCO0TLUguCp7/BT6d+ E9jg== 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; bh=ZpRAiGHrxAIp1S+RPmqFGpGzlBqUdjPBsoJh2VxfpuI=; b=q2prZ5EFCn5jOlRm+4gSxrTc7lXU58vQbjSTuvr4g0icbl2r6iEoSg6eK9p5st4q4H GwjGEolHyYRGTxepT51DIA1Ni/P94dao+4fOqbBT11W2a4RT8KWZA9N4AL0PcsIQDPfv TfWq71nCOrbsRHpzR5igGam8Xqz+AeKEWV4MckNiAZ40nRwIoWZ9CPTq432KMtzxhNlB 8lBcl6kqLPxH4DCEhsIS2azHmFqfv9IAobneqRaue6lPssf1p2wFFpL+OpuLAPKG1kou pf9E/g70OEOp0aWBbcIDBFwTwL1RALGJxlBpqK1Bb0a26HFbZpzoOU8YiODY9As+6Xhv KREA== X-Gm-Message-State: APjAAAXsECf30E7PTfBTt8/SkS918fWI1K3h3J9MjiCNu5JgHY3+8uM6 APCiB9iwdoALJWNd5i/RRDRamoNlPvhseQ== X-Google-Smtp-Source: APXvYqzkRAPQeSQ0qh6n+xAkbjjlE4Rle/q4c1dTWdQ3gq+EynWF7ZOnrNOEiidLJfqhlu4LHDEBLw== X-Received: by 2002:a17:902:8f81:: with SMTP id z1mr25690812plo.290.1560501327441; Fri, 14 Jun 2019 01:35:27 -0700 (PDT) Received: from xy-data.openstacklocal ([159.138.22.150]) by smtp.gmail.com with ESMTPSA id m31sm5207975pjb.6.2019.06.14.01.35.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Jun 2019 01:35:26 -0700 (PDT) From: Young Xiao <92siuyang@gmail.com> To: QLogic-Storage-Upstream@qlogic.com, jejb@linux.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Young Xiao <92siuyang@gmail.com> Subject: [PATCH] scsi: bnx2fc: Check if sense buffer has been allocated during completion Date: Fri, 14 Jun 2019 16:36:37 +0800 Message-Id: <1560501397-831-1-git-send-email-92siuyang@gmail.com> X-Mailer: git-send-email 2.7.4 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 sc_cmd->sense_buffer is not guaranteed to be allocated so we need to sc_cmd->check if the pointer is NULL before trying to copy anything into it. See commit 16a611154dc1 ("scsi: qedf: Check if sense buffer has been allocated during completion") for details. Signed-off-by: Young Xiao <92siuyang@gmail.com> Acked-by: Saurav Kashyap --- drivers/scsi/bnx2fc/bnx2fc_io.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c index 8def63c..44a5e59 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c @@ -1789,9 +1789,11 @@ static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req, fcp_sns_len = SCSI_SENSE_BUFFERSIZE; } - memset(sc_cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); - if (fcp_sns_len) - memcpy(sc_cmd->sense_buffer, rq_data, fcp_sns_len); + if (sc_cmd->sense_buffer) { + memset(sc_cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); + if (fcp_sns_len) + memcpy(sc_cmd->sense_buffer, rq_data, fcp_sns_len); + } /* return RQ entries */ for (i = 0; i < num_rq; i++)