Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936775AbdIZH0x (ORCPT ); Tue, 26 Sep 2017 03:26:53 -0400 Received: from mx2.suse.de ([195.135.220.15]:36183 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934953AbdIZH0t (ORCPT ); Tue, 26 Sep 2017 03:26:49 -0400 Subject: Re: [PATCH v2 1/1] scsi: fc: check for rport presence in fc_block_scsi_eh To: Johannes Thumshirn , "Martin K . Petersen" Cc: Linux SCSI Mailinglist , Linux Kernel Mailinglist , Bart Van Assche , Christoph Hellwig References: <20170926065809.7980-1-jthumshirn@suse.de> From: Hannes Reinecke Organization: SUSE Linux GmbH Message-ID: Date: Tue, 26 Sep 2017 09:26:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170926065809.7980-1-jthumshirn@suse.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1446 Lines: 46 On 09/26/2017 08:58 AM, 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 > Reviewed-by: Bart Van Assche > --- > > Changes since v1: > - s/WARN_ON/WARN_ON_ONCE/ (Bart) > > --- > 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..38abff7b5dbc 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_ONCE(!rport)) > + return 0; > + > return fc_block_rport(rport); > } > EXPORT_SYMBOL(fc_block_scsi_eh); > Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes Reinecke Teamlead Storage & Networking hare@suse.de +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)