Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2356402pxb; Sun, 30 Jan 2022 13:26:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzw3956czbT0hVynMNMTXBCD3kFTWqaFNksZIHZGgZgmh8BIrd8lRogzuyA48zCz+fZoxu+ X-Received: by 2002:a17:902:e5cc:: with SMTP id u12mr17952244plf.21.1643577967358; Sun, 30 Jan 2022 13:26:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643577967; cv=none; d=google.com; s=arc-20160816; b=bxwVLJhq5fztM9OOGQP67EKkQhDRE3UlFwunsOBSNAYZiqTMwAn4mmkj34I4pUWx45 s4W1XyqPfczdahLgVMw1jrW01SHIeZ7SrQMu8FK28kBPeXkb7lhy9Rj9j0jpErGmQBBh cJmoVYuOtRwfpJh9xL9ohYP8va+Uci900oNmUE/CMmQU1butXFk1Xo+GsGhiCG/aaqEP esP1ByZc3AAKN0l/1lQuZdUVZM8Z1vMUZnVp87tnWxT7IZm9OhdVwjzGLJsDf71Vc2jH hO/h60IvXqwFVL0lPWIBwdHsSLWrHMjBuxmNbuynBzQM0bvbcFXZMrHzpNTdLB3Wgc96 W0GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JDovsdd+AlKbKCCGJDKQDcf+O8ChFiaNubCLt+7wkIE=; b=JS1TW/wvWpgjW04+Qirf41fGI/MfQVmetyQGD2P6OHC4z6W1934rhmDkK1r27XrutR 6RARpPbUhPRdA16ofgSZJVG9OoZmbJ5BWWwbDetN1vh+h80UFKOJrpLz0PdZySFB0pnA Z7BsFjjBBjHa9WoZg3XPWefssZPwHHJaEnL86VWU/haTipmlwXL9F83rEFrZqgLIxm2s ug1oomZ9gCJq91idvcNTR4Z0zrHmDs5KaldfQvp+XE0aCJxgdGCqGpPcuXsF3KvAQbrK R5sziGdELV55gr+NERiRFS1Njjqgt9HrJBMDx1bZU4b8SAM9yXE9V+R4FP16PrGCGcS3 ScUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uVh5tmzN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f13si9254865pfv.190.2022.01.30.13.25.56; Sun, 30 Jan 2022 13:26:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uVh5tmzN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243293AbiA1KME (ORCPT + 99 others); Fri, 28 Jan 2022 05:12:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235062AbiA1KMD (ORCPT ); Fri, 28 Jan 2022 05:12:03 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A382C061714; Fri, 28 Jan 2022 02:12:03 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 28FC261E35; Fri, 28 Jan 2022 10:12:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D6C8C340E0; Fri, 28 Jan 2022 10:12:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643364722; bh=6rQJDoEfOTyNhnq1L4xauHiwGg7CtJuOe5wXI7Bu8mo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uVh5tmzNHmEgqhEx2EJvWW1anevruUpbGT5vx7qQHVweuxdOCK5RPdpDpXlQgy8eJ ZJOY0xPDe0o1/LQKEYZqgGNYikmnroEVnsnwtzZNXi0Sa9iuTrNbs62dp688F1iNyL qErpfsIqfduXy/igLYR2pPjulHvA00AfUOpcfTNg= Date: Fri, 28 Jan 2022 11:11:59 +0100 From: Greg KH To: Zhou Qingyang Cc: kjlu@umn.edu, Damien Le Moal , Alexander Shiyan , Bartlomiej Zolnierkiewicz , Jens Axboe , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ata: pata_platform: Fix a NULL pointer dereference in __pata_platform_probe() Message-ID: References: <20220124164525.53068-1-zhou1615@umn.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220124164525.53068-1-zhou1615@umn.edu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 25, 2022 at 12:45:25AM +0800, Zhou Qingyang wrote: > In __pata_platform_probe(), devm_kzalloc() is assigned to ap->ops and > there is a dereference of it right after that, which could introduce a > NULL pointer dereference bug. > > Fix this by adding a NULL check of ap->ops. > > This bug was found by a static analyzer. > > Builds with 'make allyesconfig' show no new warnings, > and our static analyzer no longer warns about this code. > > Fixes: f3d5e4f18dba ("ata: pata_of_platform: Allow to use 16-bit wide data transfer") > Signed-off-by: Zhou Qingyang > --- As stated in the past, please do not make contributions to the Linux kernel until umn.edu has properly resolved its development issues. > The analysis employs differential checking to identify inconsistent > security operations (e.g., checks or kfrees) between two code paths > and confirms that the inconsistent operations are not recovered in the > current function or the callers, so they constitute bugs. > > Note that, as a bug found by static analysis, it can be a false > positive or hard to trigger. Multiple researchers have cross-reviewed > the bug. > > drivers/ata/pata_platform.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c > index 028329428b75..021ef9cbcbc1 100644 > --- a/drivers/ata/pata_platform.c > +++ b/drivers/ata/pata_platform.c > @@ -128,6 +128,8 @@ int __pata_platform_probe(struct device *dev, struct resource *io_res, > ap = host->ports[0]; > > ap->ops = devm_kzalloc(dev, sizeof(*ap->ops), GFP_KERNEL); > + if (ap->ops) > + return -ENOMEM; This change seems to leak memory. Damien, please revert it. thanks, greg k-h