From patchwork Sat Aug 8 07:26:25 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 40098 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n787QQUu021611 for ; Sat, 8 Aug 2009 07:26:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754453AbZHHH03 (ORCPT ); Sat, 8 Aug 2009 03:26:29 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754460AbZHHH03 (ORCPT ); Sat, 8 Aug 2009 03:26:29 -0400 Received: from wf-out-1314.google.com ([209.85.200.173]:9490 "EHLO wf-out-1314.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754453AbZHHH02 (ORCPT ); Sat, 8 Aug 2009 03:26:28 -0400 Received: by wf-out-1314.google.com with SMTP id 26so753205wfd.4 for ; Sat, 08 Aug 2009 00:26:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:subject:to:cc:date :in-reply-to:references:user-agent:mime-version:content-type :content-transfer-encoding:message-id; bh=hruoIbweCyfLZdZiWw+38iqmTxaazfwj++mFG9Yjp+4=; b=B9dj2OODlRf8j5loo4481/+0GdJZZCtQ9/t+MqQbdjKXwqJ35JSQNAiTU0shqa9S+V KzEkrZ4Rhni7e/Y7NDJIFdvt0YcnVbwKjoQKxiW2SucaMBWvqZPOQK4MgCclwgTCGHch RWhRAFVF3mKYZpoyNk+HI1BqqFbV6rg4jYwAE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:subject:to:cc:date:in-reply-to:references:user-agent :mime-version:content-type:content-transfer-encoding:message-id; b=mF8EB9OIPNPiAm+xqICnjUF6y1USLL8pcnWa43pwo0vifG9bWNjKK6ygURjVJDcDvV WWZe2Kew79KcLZu3oRGfLdldOtunzc/Zr/1kdV2ZmDUubfQiGOaZIONeMUYWT6ySBKih wlw5kUqKNSLkSWXzbplJhYwjptihs2lJ/UhHw= Received: by 10.142.148.9 with SMTP id v9mr496881wfd.148.1249716389435; Sat, 08 Aug 2009 00:26:29 -0700 (PDT) Received: from mailhub.coreip.homeip.net (c-24-6-153-137.hsd1.ca.comcast.net [24.6.153.137]) by mx.google.com with ESMTPS id k37sm8430506rvb.8.2009.08.08.00.26.27 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 08 Aug 2009 00:26:28 -0700 (PDT) From: Dmitry Torokhov Subject: [PATCH 2/4] ACPI: video - fix potential crash when unloading To: Len Brown Cc: Zhang Rui , linux-acpi@vger.kernel.org Date: Sat, 08 Aug 2009 00:26:25 -0700 In-Reply-To: <20090808072150.2980.3863.stgit@localhost.localdomain> References: <20090808072150.2980.3863.stgit@localhost.localdomain> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Message-Id: <20090808075636.C8B31526EC9@mailhub.coreip.homeip.net> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org thermal_cooling_device_register() returns error encoded in a pointer when it fails in which case we need to explictly set device->cdev to NULL so we don't try to unregister it when unloading. Signed-off-by: Dmitry Torokhov Acked-by: Zhang Rui --- drivers/acpi/video.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index d8e64cf..98ade4e 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -992,8 +992,18 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) device->cdev = thermal_cooling_device_register("LCD", device->dev, &video_cooling_ops); - if (IS_ERR(device->cdev)) + if (IS_ERR(device->cdev)) { + /* + * Set cdev to NULL so we don't crash trying to + * free it. + * Also, why the hell we are returnign early and + * not attempt to register video output if cooling + * device registration failed? + * -- dtor + */ + device->cdev = NULL; return; + } dev_info(&device->dev->dev, "registered as cooling_device%d\n", device->cdev->id);