Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754772AbbB0In3 (ORCPT ); Fri, 27 Feb 2015 03:43:29 -0500 Received: from mail-we0-f169.google.com ([74.125.82.169]:43574 "EHLO mail-we0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752093AbbB0In2 convert rfc822-to-8bit (ORCPT ); Fri, 27 Feb 2015 03:43:28 -0500 Message-ID: <54F02E22.5050901@bschorr.de> Date: Fri, 27 Feb 2015 09:43:14 +0100 From: "Thorsten.Bschorr" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de; rv:1.8.1.19) Gecko/20081209 Thunderbird/2.0.0.19 Mnenhy/0.7.5.0 MIME-Version: 1.0 To: linux-kernel@vger.kernel.org CC: Evgeniy Polyakov , David Fries Subject: [PATCH] Avoid null-pointer access in w1/slaves/w1_therm References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Antivirus: avast! (VPS 150226-1, 26.02.2015), Outbound message X-Antivirus-Status: Clean Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1316 Lines: 39 w1_slave_show unlocks the bus while waiting for the sensor to convert the temperature. If the sensor gets disconnected during that time, sl->family_data could get NULL. Note: the w1_slave pointer inside w1_slave_show is protected by sysfs-mutex --- drivers/w1/slaves/w1_therm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c index 1f11a20..3a14cb1 100644 --- a/drivers/w1/slaves/w1_therm.c +++ b/drivers/w1/slaves/w1_therm.c @@ -236,6 +236,12 @@ static ssize_t w1_slave_show(struct device *device, i = mutex_lock_interruptible(&dev->bus_mutex); if (i != 0) return i; + + /* Ensure that device is still there - + * it could have gone while we unlocked the bus. + * Note: sl is still protected by sysfs-mutex */ + if(!sl->family_data) + return -ENODEV; } else if (!w1_strong_pullup) { sleep_rem = msleep_interruptible(tm); if (sleep_rem != 0) { -- 1.8.4.5 --- Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft. http://www.avast.com -- 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/