From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754770Ab1HWIdX (ORCPT ); Tue, 23 Aug 2011 04:33:23 -0400 Received: from mgw2.diku.dk ([130.225.96.92]:56227 "EHLO mgw2.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752587Ab1HWIdS (ORCPT ); Tue, 23 Aug 2011 04:33:18 -0400 Date: Tue, 23 Aug 2011 10:33:12 +0200 (CEST) From: Julia Lawall To: "Zou, Yi" Cc: Jesper Juhl , "linux-scsi@vger.kernel.org" , "kernel-janitors@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "James E.J. Bottomley" , "devel@open-fcoe.org" Subject: RE: [Open-FCoE] [PATCH 2/4] drivers/scsi/fcoe/fcoe.c: add missing test In-Reply-To: <5A9BD224CEA58D4CB62235967D650C1609F5B04B@orsmsx509.amr.corp.intel.com> Message-ID: References: <1314021636-11528-2-git-send-email-julia@diku.dk> <5A9BD224CEA58D4CB62235967D650C1609F5B04B@orsmsx509.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 23 Aug 2011, Zou, Yi wrote: > > From nobody Mon Aug 22 15:57:42 CEST 2011 > > From: Julia Lawall > > To: Robert Love > > Cc: "James E.J. Bottomley" ,devel@open- > > fcoe.org,linux-scsi@vger.kernel.org,linux-kernel@vger.kernel.org > > Subject: [PATCH 2/4] drivers/scsi/fcoe/fcoe.c: add missing test > > > > From: Julia Lawall > > > > The initializations of both fcoe_nport_scsi_transport and > > fcoe_vport_scsi_transport can fail, so test both of them. > > > > The semantic match that finds this problem is as follows: > > (http://coccinelle.lip6.fr/) > > > > // > > @r@ > > identifier x,y,f!={PTR_ERR,ERR_PTR,ERR_CAST}; > > statement S; > > @@ > > > > x = f(...); > > ( > > if (\(x == NULL\|IS_ERR(x)\)) S > > | > > *if (\(y == NULL\|IS_ERR(y)\)) > > { ... when != x > > return ...; } > > ) > > // > > > > Signed-off-by: Julia Lawall > > > > --- > > drivers/scsi/fcoe/fcoe.c | 13 +++++++++++-- > > 1 file changed, 11 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c > > index ba710e3..9f2e2f4 100644 > > --- a/drivers/scsi/fcoe/fcoe.c > > +++ b/drivers/scsi/fcoe/fcoe.c > > @@ -1093,11 +1093,20 @@ static int __init fcoe_if_init(void) > > /* attach to scsi transport */ > > fcoe_nport_scsi_transport = > > fc_attach_transport(&fcoe_nport_fc_functions); > > + > > + if (!fcoe_nport_scsi_transport) { > > + printk(KERN_ERR > > + "fcoe_nport: Failed to attach to the FC transport\n"); > > + return -ENODEV; > > + } > > + > > fcoe_vport_scsi_transport = > > fc_attach_transport(&fcoe_vport_fc_functions); > > > > - if (!fcoe_nport_scsi_transport) { > > - printk(KERN_ERR "fcoe: Failed to attach to the FC > > transport\n"); > > + if (!fcoe_vport_scsi_transport) { > > + printk(KERN_ERR > > + "fcoe_vport: Failed to attach to the FC transport\n"); > > + fc_release_transport(fcoe_nport_scsi_transport); > > return -ENODEV; > > } > > > > I understand we were using -ENODEV before, but -ENOMEM is preferred here > as that's the only err from fc_attach_transport. OK, I'll fix it. Thanks. julia