Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5606142imu; Mon, 26 Nov 2018 02:55:09 -0800 (PST) X-Google-Smtp-Source: AFSGD/WE58Bd5HputcJp6fYfFznUMh33lAFfDQNqOLbdtVPgS4PWgbDxKBIIwkimoJwAjTJr8fNK X-Received: by 2002:a17:902:20e9:: with SMTP id v38mr24716092plg.250.1543229709039; Mon, 26 Nov 2018 02:55:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543229709; cv=none; d=google.com; s=arc-20160816; b=ynghIgr8fXNYFhp5RhGXa+DIUh5WpgcJvAVhl2Sm8ty3XZ1TNmEaDDJ+ZgxLlfOeMz dee4huSlunr2G4kbgz+T9thikIyOo7edxygm561mKXTjfxt1H4NO7ePP2gH78vF/3f6v fE8QDLdaWRtwWWa8TvkSdwx2Enr9/yybXXSd+Y8hnFKuZlE+NjeIGTyDni5euyCVega8 V6IDYRs+6zjZfD7MGb3aimILp3ygICgEgG10Wf/XuE1yVJg1CTYsOeBrM09fZKUKr3/O lVqczRdxpeDd0vSFbnhzS6XE5yThfI9fG6P8Ph59kfpQqmzSv01MBtzcnxwzTL6WQQHS Jpzg== 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=FfCugsGAwl3toEu5lZKrI5U0/cPIIPimQwU6bngJ5Zs=; b=yql/1LyQCalETEbJilZZH/qhkuxDs+ZjZ2Px0y9Olsqi42IItbiOTx4Cpsm+1/r41A Cv1GjucMRllItGe+huYL9Un1joSCg9vtrrII0KRLq51GF0Mb8hrCUlvKskoM8RVvsgpC bv3gxEE3UlKRYwD9X4eRBfjezvj9suGXQ6pidcGpqOXZkMicaNporIv5PPoaHatAmORC RhE6NWvvDxzhhhRsMFM+ubIKKlMmFstivXGXLA/Ohdo4idVCL1ZHbmQw3kvu3N2YJinw DZHQs1IAQZbmcR7coKiMS06OIwjVFhuBvxR3CVsD9iVlrJbPYMqJXXu+p5qWVRsopX7h Ddyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r6mzWfaW; 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 c22si43348179pgb.254.2018.11.26.02.54.53; Mon, 26 Nov 2018 02:55:09 -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=r6mzWfaW; 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 S1726561AbeKZVql (ORCPT + 99 others); Mon, 26 Nov 2018 16:46:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:54576 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726524AbeKZVqk (ORCPT ); Mon, 26 Nov 2018 16:46:40 -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 3C46921479; Mon, 26 Nov 2018 10:52:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543229576; bh=ptnjmNxjOY6t3R3FWznFPI0QGCec8fOWmCtccptT/kc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r6mzWfaWc6cJPs2aJJQb85AdAeK0Fq3KAV4oRTl9eCviyNEN2SM5MPXSPyHeESrEA Ryrkb4o5Ic64YKvH3bBrF124llwMHb/6WR+ybKWtD8cjt+FG0D/N5YGrsbsmlWc45S vPjVySH6QArxZpbnjktuBc1AFIkZBObFZJPvSeWk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathias Thore , Dan Carpenter Subject: [PATCH 3.18 16/24] uio: Fix an Oops on load Date: Mon, 26 Nov 2018 11:51:10 +0100 Message-Id: <20181126105032.100557952@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105029.790599475@linuxfoundation.org> References: <20181126105029.790599475@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 3.18-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 @@ -841,14 +841,17 @@ 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)) { ret = devm_request_irq(idev->dev, 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: