Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759249AbYGQAfd (ORCPT ); Wed, 16 Jul 2008 20:35:33 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752967AbYGQAfX (ORCPT ); Wed, 16 Jul 2008 20:35:23 -0400 Received: from e35.co.us.ibm.com ([32.97.110.153]:39703 "EHLO e35.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751720AbYGQAfW (ORCPT ); Wed, 16 Jul 2008 20:35:22 -0400 Subject: [scsi_dh] [PATCH] Verify "dev" is a sdev before accessing it. From: Chandra Seetharaman Reply-To: sekharan@us.ibm.com To: Linus Torvalds , "James.Bottomley" Cc: linux-scsi , Yinghai Lu , linux-kernel Content-Type: text/plain Organization: IBM Date: Wed, 16 Jul 2008 17:35:08 -0700 Message-Id: <1216254908.27507.245.camel@chandra-ubuntu> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2964 Lines: 84 Before accessing the device data structure in hardware handlers, make sure it is a indeed a sdev device. Yinghai Lu found the bug on Jul 16, 2008, and later tested/verified the following fix. Signed-off-by: Chandra Seetharaman -- Index: linux2.6.26-git3/drivers/scsi/device_handler/scsi_dh_rdac.c =================================================================== --- linux2.6.26-git3.orig/drivers/scsi/device_handler/scsi_dh_rdac.c +++ linux2.6.26-git3/drivers/scsi/device_handler/scsi_dh_rdac.c @@ -608,12 +608,17 @@ static int rdac_bus_notify(struct notifi unsigned long action, void *data) { struct device *dev = data; - struct scsi_device *sdev = to_scsi_device(dev); + struct scsi_device *sdev; struct scsi_dh_data *scsi_dh_data; struct rdac_dh_data *h; int i, found = 0; unsigned long flags; + if (!scsi_is_sdev_device(dev)) + return 0; + + sdev = to_scsi_device(dev); + if (action == BUS_NOTIFY_ADD_DEVICE) { for (i = 0; rdac_dev_list[i].vendor; i++) { if (!strncmp(sdev->vendor, rdac_dev_list[i].vendor, Index: linux2.6.26-git3/drivers/scsi/device_handler/scsi_dh_emc.c =================================================================== --- linux2.6.26-git3.orig/drivers/scsi/device_handler/scsi_dh_emc.c +++ linux2.6.26-git3/drivers/scsi/device_handler/scsi_dh_emc.c @@ -416,12 +416,17 @@ static int clariion_bus_notify(struct no unsigned long action, void *data) { struct device *dev = data; - struct scsi_device *sdev = to_scsi_device(dev); + struct scsi_device *sdev; struct scsi_dh_data *scsi_dh_data; struct clariion_dh_data *h; int i, found = 0; unsigned long flags; + if (!scsi_is_sdev_device(dev)) + return 0; + + sdev = to_scsi_device(dev); + if (action == BUS_NOTIFY_ADD_DEVICE) { for (i = 0; clariion_dev_list[i].vendor; i++) { if (!strncmp(sdev->vendor, clariion_dev_list[i].vendor, Index: linux2.6.26-git3/drivers/scsi/device_handler/scsi_dh_hp_sw.c =================================================================== --- linux2.6.26-git3.orig/drivers/scsi/device_handler/scsi_dh_hp_sw.c +++ linux2.6.26-git3/drivers/scsi/device_handler/scsi_dh_hp_sw.c @@ -131,11 +131,16 @@ static int hp_sw_bus_notify(struct notif unsigned long action, void *data) { struct device *dev = data; - struct scsi_device *sdev = to_scsi_device(dev); + struct scsi_device *sdev; struct scsi_dh_data *scsi_dh_data; int i, found = 0; unsigned long flags; + if (!scsi_is_sdev_device(dev)) + return 0; + + sdev = to_scsi_device(dev); + if (action == BUS_NOTIFY_ADD_DEVICE) { for (i = 0; hp_sw_dh_data_list[i].vendor; i++) { if (!strncmp(sdev->vendor, hp_sw_dh_data_list[i].vendor, -- 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/