Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5667539imu; Mon, 26 Nov 2018 03:47:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/U+shTQnhNpchHK6arfCmO5zKMNxy9nQQ5LLdzV+s+rCAFUf1Wluq7+nI9J2Iz6eoxigXW7 X-Received: by 2002:a62:6e07:: with SMTP id j7mr11007815pfc.135.1543232858929; Mon, 26 Nov 2018 03:47:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543232858; cv=none; d=google.com; s=arc-20160816; b=n9O81Nm1S01AM3AZTbHqMRdUoQxjyAxDyl/pA8+KkWsDMS2IX8NxjZ6rD9PE7YJT1G QX8CZ/UzkK9e0xQRHGwB8rNdf0U0TiKY+IW7MSh/bbkJ3vzhV7Ilmdra7c0z1d9Gf2HZ +6WSO3gsS7NZejX3AQIXxvNMt60glCBqNW+plgPoCKE6sgDdoTwlfjcMiM7/s+qRTqgo Cz0+UyWgB6zFfWALBcIa17fJ8u5jKFpMELf/PSTcyfFi1DHW0g+mCCuyByZ/t1PAxad/ MwplCxv/6kH2s0lebsKcP7siFdzEN/hF8wi7717XX8g8ikcRAyNKZOHgZBJAN5Yj/0Ft wo2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=t9uMRuz8mqouPpDNALa4Llxzjzqnkzc9qdnwoK9vaYA=; b=DtTQaG1cSC6BdRzsSg5Rt63HQb3ugzpa0X0EwRG8Xq9rtw+p0KBphK9m6ZQ4J0fLp0 cIE4b6kd/m+gyj6ClVqKR1WTkgVxnHV87JNI5HZAPoE/IRYKp2k3yuOB0db/xK0uBkih i747969avaavwqN8SDBhcyMTULu6pDd9rTr3W4XwRtGlwssKu6Et7PnBy/wCOUui41FV EMYoPqOeh7gVzikqsjcqU7Dzgej0HVat/qEyUDyGJLkuiEV9+nC6m52/dRyOls2lVdCA EPtyuYJ4CHWH0E243iT4ORjmpRIhIzS+jwO0dGDfOZcs/PXPw7APBsJ1SJYl4QdKwgjH zqaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=W0XEvvxf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r27si58075pgl.494.2018.11.26.03.47.13; Mon, 26 Nov 2018 03:47:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=W0XEvvxf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728178AbeKZVtk (ORCPT + 99 others); Mon, 26 Nov 2018 16:49:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:58660 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726561AbeKZVtj (ORCPT ); Mon, 26 Nov 2018 16:49:39 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CCCAA21104; Mon, 26 Nov 2018 10:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543229755; bh=CNKQ1xum+qhbqOllBcoIZSnibIeZCm0ZAP7d8zQx7TM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W0XEvvxfaFum8C9xgjCuXBVt+hU63pbGs3zdL7K8Yaw1ylsTmNFp3cm2mKt5OYhSa Ddf4jL76xJPc13X7C6/jMcn9brQncyHTl65i7YMWhQxnapAqcFEL0prLcVGVzs5sFq kGRFNT9M6TL5CZhqR7UKmBmywkuUsqd0BukU8pNQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathias Thore , Dan Carpenter Subject: [PATCH 4.4 61/70] uio: Fix an Oops on load Date: Mon, 26 Nov 2018 11:51:16 +0100 Message-Id: <20181126105052.562947899@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105046.722096341@linuxfoundation.org> References: <20181126105046.722096341@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter commit 432798195bbce1f8cd33d1c0284d0538835e25fb upstream. I was trying to solve a double free but I introduced a more serious NULL dereference bug. The problem is that if there is an IRQ which triggers immediately, then we need "info->uio_dev" but it's not set yet. This patch puts the original initialization back to how it was and just sets info->uio_dev to NULL on the error path so it should solve both the Oops and the double free. Fixes: f019f07ecf6a ("uio: potential double frees if __uio_register_device() fails") Reported-by: Mathias Thore Signed-off-by: Dan Carpenter Cc: stable Tested-by: Mathias Thore Signed-off-by: Greg Kroah-Hartman --- drivers/uio/uio.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -842,6 +842,8 @@ int __uio_register_device(struct module if (ret) goto err_uio_dev_add_attributes; + info->uio_dev = idev; + if (info->irq && (info->irq != UIO_IRQ_CUSTOM)) { /* * Note that we deliberately don't use devm_request_irq @@ -853,11 +855,12 @@ int __uio_register_device(struct module */ ret = request_irq(info->irq, uio_interrupt, info->irq_flags, info->name, idev); - if (ret) + if (ret) { + info->uio_dev = NULL; goto err_request_irq; + } } - info->uio_dev = idev; return 0; err_request_irq: