From patchwork Sun Oct 7 08:35:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 10629419 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 8CF9A14BD for ; Sun, 7 Oct 2018 08:35:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BC7629150 for ; Sun, 7 Oct 2018 08:35:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FE1A29199; Sun, 7 Oct 2018 08:35:49 +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=-7.9 required=2.0 tests=BAYES_00,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 1546C29150 for ; Sun, 7 Oct 2018 08:35:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728000AbeJGPmU (ORCPT ); Sun, 7 Oct 2018 11:42:20 -0400 Received: from mx2.suse.de ([195.135.220.15]:47120 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727686AbeJGPmT (ORCPT ); Sun, 7 Oct 2018 11:42:19 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8F83CADD8; Sun, 7 Oct 2018 08:35:45 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Chad Dupuis , Arun Easi , Thomas Abraham Subject: [PATCH 2/3] libfc: check fc_frame_payload_get() return value for null Date: Sun, 7 Oct 2018 10:35:36 +0200 Message-Id: <20181007083537.89131-3-hare@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20181007083537.89131-1-hare@suse.de> References: <20181007083537.89131-1-hare@suse.de> 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 From: Thomas Abraham We should not assume the payload of a PRLI or PLOGI respons is always present. Signed-off-by: Thomas Abraham Reviewed-by: Hannes Reinecke Reviewed-by: Arun Easi --- drivers/scsi/libfc/fc_rport.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c index 372387a450df..e400783ebb87 100644 --- a/drivers/scsi/libfc/fc_rport.c +++ b/drivers/scsi/libfc/fc_rport.c @@ -1038,8 +1038,11 @@ static void fc_rport_plogi_resp(struct fc_seq *sp, struct fc_frame *fp, struct fc_els_ls_rjt *rjt; rjt = fc_frame_payload_get(fp, sizeof(*rjt)); - FC_RPORT_DBG(rdata, "PLOGI ELS rejected, reason %x expl %x\n", - rjt->er_reason, rjt->er_explan); + if (!rjt) + FC_RPORT_DBG(rdata, "PLOGI bad response\n"); + else + FC_RPORT_DBG(rdata, "PLOGI ELS rejected, reason %x expl %x\n", + rjt->er_reason, rjt->er_explan); fc_rport_error_retry(rdata, -FC_EX_ELS_RJT); } out: @@ -1211,8 +1214,11 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct fc_frame *fp, } else { rjt = fc_frame_payload_get(fp, sizeof(*rjt)); - FC_RPORT_DBG(rdata, "PRLI ELS rejected, reason %x expl %x\n", - rjt->er_reason, rjt->er_explan); + if (!rjt) + FC_RPORT_DBG(rdata, "PRLI bad response\n"); + else + FC_RPORT_DBG(rdata, "PRLI ELS rejected, reason %x expl %x\n", + rjt->er_reason, rjt->er_explan); fc_rport_error_retry(rdata, FC_EX_ELS_RJT); }