Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932958Ab2EQVUh (ORCPT ); Thu, 17 May 2012 17:20:37 -0400 Received: from nat.nue.novell.com ([195.135.221.2]:25626 "EHLO nat.nue.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760661Ab2EQVUf (ORCPT ); Thu, 17 May 2012 17:20:35 -0400 Message-ID: <4FB56B9C.8080109@suse.com> Date: Thu, 17 May 2012 14:20:28 -0700 From: Lee Duncan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120421 Thunderbird/12.0 MIME-Version: 1.0 To: linux-scsi@vger.kernel.org CC: linux-kernel@vger.kernel.org, kai.makisara@kolumbus.fi, jeffm@suse.com Subject: [PATCH v2 2/5] st: clean up dev cleanup in st_probe X-Enigmail-Version: 1.4.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1606 Lines: 54 From: Jeff Mahoney st_probe leaves a cdev pointer hanging around that is compared during the error path and freed later. There's no need for the pointer to hang around at all. So we free it immediately and simplify the error handling. Signed-off-by: Jeff Mahoney Signed-off-by: Lee Duncan --- drivers/scsi/st.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 532543c..40f9d47 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -4156,6 +4156,7 @@ static int st_probe(struct device *dev) printk(KERN_ERR "st%d: out of memory. Device not attached.\n", dev_num); + cdev_del(cdev); goto out_free_tape; } cdev->owner = THIS_MODULE; @@ -4194,17 +4195,13 @@ out_free_tape: "tape"); for (j=0; j < 2; j++) { if (STm->cdevs[j]) { - if (cdev == STm->cdevs[j]) - cdev = NULL; - device_destroy(&st_sysfs_class, - MKDEV(SCSI_TAPE_MAJOR, - TAPE_MINOR(i, mode, j))); + device_destroy(&st_sysfs_class, + MKDEV(SCSI_TAPE_MAJOR, + TAPE_MINOR(i, mode, j))); cdev_del(STm->cdevs[j]); } } } - if (cdev) - cdev_del(cdev); write_lock(&st_dev_arr_lock); scsi_tapes[dev_num] = NULL; st_nr_dev--; -- 1.7.9.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/