Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966373AbdIYX3M (ORCPT ); Mon, 25 Sep 2017 19:29:12 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:58707 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966123AbdIYX3L (ORCPT ); Mon, 25 Sep 2017 19:29:11 -0400 X-IronPort-AV: E=Sophos;i="5.42,438,1500912000"; d="scan'208";a="54053588" From: Bart Van Assche To: "jthumshirn@suse.de" , "martin.petersen@oracle.com" CC: "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "hch@lst.de" , "hare@suse.de" , Bart Van Assche Subject: Re: [PATCH] scsi: fc: check for rport presence in fc_block_scsi_eh Thread-Topic: [PATCH] scsi: fc: check for rport presence in fc_block_scsi_eh Thread-Index: AQHTNfX3dx9Qm2R5+UWSH2J8pKB4u6LGQDwA Date: Mon, 25 Sep 2017 23:29:07 +0000 Message-ID: <1506382146.2641.61.camel@wdc.com> References: <20170925120049.19689-1-jthumshirn@suse.de> In-Reply-To: <20170925120049.19689-1-jthumshirn@suse.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; x-originating-ip: [63.163.107.100] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY1PR0401MB1536;20:VwXtiHP8ORicY62/O9Nj2RGN5LwlxHUgF1rKnU0SZpzlHXPDakz+hhoyxxy0n849lTZscXZXhK+OmMiyGUk5RKQraDaI6rvMytliCH1x8grgwYxIVDwThvTLwWfGWXo+ioC93pXKFBH4lzGgRLBYw20WNNN81YhLYbjkWzZKyq0= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-correlation-id: 3304c548-b6f0-4d6a-9ae4-08d5046d3805 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254152)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075);SRVR:CY1PR0401MB1536; x-ms-traffictypediagnostic: CY1PR0401MB1536: wdcipoutbound: EOP-TRUE x-exchange-antispam-report-test: UriScan:; x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041248)(20161123562025)(20161123564025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY1PR0401MB1536;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY1PR0401MB1536; x-forefront-prvs: 04410E544A x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(376002)(39860400002)(346002)(377424004)(24454002)(199003)(189002)(6512007)(54906003)(53936002)(25786009)(81156014)(5660300001)(14454004)(2900100001)(6436002)(81166006)(68736007)(3660700001)(3846002)(8676002)(6486002)(6506006)(229853002)(2906002)(99286003)(189998001)(6116002)(77096006)(3280700002)(8936002)(4326008)(97736004)(72206003)(478600001)(305945005)(6246003)(102836003)(66066001)(2501003)(76176999)(36756003)(316002)(101416001)(33646002)(7736002)(103116003)(54356999)(2950100002)(86362001)(105586002)(110136005)(106356001)(50986999);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0401MB1536;H:CY1PR0401MB1536.namprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: <55FAF15C62D8C14C81FDE6D45A3AEB8B@namprd04.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Sep 2017 23:29:08.0005 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0401MB1536 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v8PNTgjc016584 Content-Length: 1150 Lines: 32 On Mon, 2017-09-25 at 14:00 +0200, Johannes Thumshirn wrote: > Coverity-scan recently found a possible NULL pointer dereference in > fc_block_scsi_eh() as starget_to_rport() either returns the rport for > the startget or NULL. > > While it is rather unlikely to have fc_block_scsi_eh() called without > an rport associated it's a good idea to catch potential misuses of the > API gracefully. > > Signed-off-by: Johannes Thumshirn > --- > drivers/scsi/scsi_transport_fc.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c > index ba9d70f8a6a1..830ce53f30fb 100644 > --- a/drivers/scsi/scsi_transport_fc.c > +++ b/drivers/scsi/scsi_transport_fc.c > @@ -3328,6 +3328,9 @@ int fc_block_scsi_eh(struct scsi_cmnd *cmnd) > { > struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device)); > > + if (WARN_ON(!rport)) > + return 0; > + > return fc_block_rport(rport); > } > EXPORT_SYMBOL(fc_block_scsi_eh); Did you perhaps intend to use WARN_ON_ONCE() instead of WARN_ON()? Anyway: Reviewed-by: Bart Van Assche