Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3546031pxj; Mon, 24 May 2021 09:05:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/owXKmFFw2IDwVEKlvghUWCaMuYlVCJ4lYrAV6uhoSiWvG5PfvhJWL4OpVzt6vfWYAmaG X-Received: by 2002:a05:6e02:1067:: with SMTP id q7mr16267924ilj.75.1621872325301; Mon, 24 May 2021 09:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872325; cv=none; d=google.com; s=arc-20160816; b=e6GRhSbMxs2t0dAPRCryHiNQD+1U2SDCjivQb47/XcPHm4HJoT0neHz8xyf1M6Su6b lMdndkzKRwdDgtiAOzIjQFgAN+KESctU2ddaY7DrtYst+a44PIdzZrzi9qRJcY5yWGY/ 8LE14l1VGbxRA21KAXnsoIS2FGjfW59ohQCtmBWTHAT5ynsGWFVzKhb4Fb7euovZnzjc 0YTMtdi/McNCsdB7LhRWPNsGU4TxGQHw9sjor+MYQwlZBaS4MVsv3T14K+cFJehd6Iaz Qv6Vk+QUUqa/U38o6+Zumaqp0zdLNnpykWSsPi498iRKRshwd5Pd17ed7tVrN+QG+vsb 6S4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9rl5KPM+d6uGcs7yQ2Tqy9zs38v9L9TUEGkgz/ZS4dE=; b=lig/C4DEWHi9toEaX0rpCR7uUnR+2OpxArF0AbpZS/oPAh6jwsiOXAmLTl8E/DC7ds Ju1Ep3+tO/ddQxZHFljcF/b/ibGSrUg77WX9QzWlw5VXe6jJ1KTSDjXs76Y3NLZ+yaXc umFdUJLS7PeCNCFglDVev7XKxgCR5GSDisbz1zYpfEaXI8QpLua1adcPwhsWOYxtlVlN cBNsIxaZCJ0w1qWPf3bmF9Dqr8k/Zgb2ZSlAcFxXFshkk9B33WZLgXnyZ6YDYh6xcwID 3dCC2c699OpRvumNL9YDP0JdAxGb+SFW8qH/hEMxFHL76CfzJHnHuGuxOQNWfBRXrlmR Q+1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yBGKjWUn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g15si14422818iln.71.2021.05.24.09.05.06; Mon, 24 May 2021 09:05:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yBGKjWUn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236831AbhEXQEj (ORCPT + 99 others); Mon, 24 May 2021 12:04:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:41116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234255AbhEXP6D (ORCPT ); Mon, 24 May 2021 11:58:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 943F861960; Mon, 24 May 2021 15:43:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621871040; bh=oIaaE+lymUrXstD0xnY07JxPAhOLYAqdHuB9GSYkgWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yBGKjWUnHjQeZjyF/v7Moj4oK4y0KKVjqsnOBz6ftxM1lqTSR0ns2c1kmNZ0qVJuZ vTTaDDfiqgrpNCqbCjD2LcslnHFQWXrZhaunSbHWY2yfw6cwwrjlyPrjrFTPWAEZK8 0g2qShezaMuwPC9SZgk3c4T5RESEvdv9kE/TPSEY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Himanshu Madhani , Javed Hasan , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.12 011/127] scsi: qedf: Add pointer checks in qedf_update_link_speed() Date: Mon, 24 May 2021 17:25:28 +0200 Message-Id: <20210524152335.237280989@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152334.857620285@linuxfoundation.org> References: <20210524152334.857620285@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Javed Hasan [ Upstream commit 73578af92a0fae6609b955fcc9113e50e413c80f ] The following trace was observed: [ 14.042059] Call Trace: [ 14.042061] [ 14.042068] qedf_link_update+0x144/0x1f0 [qedf] [ 14.042117] qed_link_update+0x5c/0x80 [qed] [ 14.042135] qed_mcp_handle_link_change+0x2d2/0x410 [qed] [ 14.042155] ? qed_set_ptt+0x70/0x80 [qed] [ 14.042170] ? qed_set_ptt+0x70/0x80 [qed] [ 14.042186] ? qed_rd+0x13/0x40 [qed] [ 14.042205] qed_mcp_handle_events+0x437/0x690 [qed] [ 14.042221] ? qed_set_ptt+0x70/0x80 [qed] [ 14.042239] qed_int_sp_dpc+0x3a6/0x3e0 [qed] [ 14.042245] tasklet_action_common.isra.14+0x5a/0x100 [ 14.042250] __do_softirq+0xe4/0x2f8 [ 14.042253] irq_exit+0xf7/0x100 [ 14.042255] do_IRQ+0x7f/0xd0 [ 14.042257] common_interrupt+0xf/0xf [ 14.042259] API qedf_link_update() is getting called from QED but by that time shost_data is not initialised. This results in a NULL pointer dereference when we try to dereference shost_data while updating supported_speeds. Add a NULL pointer check before dereferencing shost_data. Link: https://lore.kernel.org/r/20210512072533.23618-1-jhasan@marvell.com Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.") Reviewed-by: Himanshu Madhani Signed-off-by: Javed Hasan Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/qedf/qedf_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index cec27f2ef70d..e5076f09d5ed 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -536,7 +536,9 @@ static void qedf_update_link_speed(struct qedf_ctx *qedf, if (linkmode_intersects(link->supported_caps, sup_caps)) lport->link_supported_speeds |= FC_PORTSPEED_20GBIT; - fc_host_supported_speeds(lport->host) = lport->link_supported_speeds; + if (lport->host && lport->host->shost_data) + fc_host_supported_speeds(lport->host) = + lport->link_supported_speeds; } static void qedf_bw_update(void *dev) -- 2.30.2