Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp126531lqc; Thu, 7 Mar 2024 12:16:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW30xN2/yOn0PGGV+SZUsUV3feIDT5DdsVhB02Qcy6iNFr2Y1Lbqie0XBbjJ1Nq5pmgCEa3cQniAPNk+mT0Is/EjuTpAh3mB6CWb7WIqw== X-Google-Smtp-Source: AGHT+IFQ37Lv68QDlVj1huNVKEf9rYuKoD1EtIw6zbYZXCCEiyTgOr9C7fRl/qmjsewvw7pQp61z X-Received: by 2002:a17:902:6e0f:b0:1dd:5f85:1191 with SMTP id u15-20020a1709026e0f00b001dd5f851191mr1545291plk.53.1709842584136; Thu, 07 Mar 2024 12:16:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709842584; cv=pass; d=google.com; s=arc-20160816; b=O4H/0LW9Bmd6jV7qL5oCvltwvXZpVRLp67WCOH1leQFHZjrTMwOkYTEVmNtxcCmJst /wgKia34YWNT/AzNC5ctJPHUK3/SnRCs293Lv2ayv03qhCAvo1cnjNikzqyPjb+Uy0A0 8eYDO3bFTdoAd1Cirfw2JHJYDfyv+ScnXnWp4+v9/vEbRn37oKFqMz7fNrlydOnNDS0j wfVBy5AXE9a8bLhraNuVXHimmZcZBCL/KfECufQhqxxIT2jVPPxcnjpV5eNzqr+tTqP1 bTuctp5O0BXn3l5OW+J6kCiwhWz3p5Ql2SYJ7eMi2q4O+9OSxOQ6HH2rnuaRFL8KfZ63 eteA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=rdXWMDWHAYLWBFHIm7+hKmB5IJt2qBntfzqSsWESjAo=; fh=7Af1EZ+qqfgAWrKqNWdRwumz8swwovGfj5WjjVXyYCQ=; b=n04+305D9C2HmQ/h9cjSl4Tbt9re2vgbKCMuXg1PFV1lQF3flaCfu42ko/GESEDiFR A55JrwDFTbUIAfrd/khyIBa2ymq0ZoYU74b+AFHVnyaNS9BUiMkKD8TzNLi2gF3ey93T AJ9zg4TxaNtYN7WQm+mGXTQi9Sf3H7KXD/CTHARzGhFFySynW0iXsOI31OPlz0PyUS0x aWonNQ5laQMqvIcfGNMPOFNWkmgu8OkqGzPGONTPtZLiopurUlsNGDjiFLN3N8NqHfH5 FYqwjtsHVd0vk8YuJjyOCNu6Dj+AjgXKCskKoeyR7ybZAE8qMwoTEIAA7V9Qw+WIxQJx ouow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=c--e.de); spf=pass (google.com: domain of linux-kernel+bounces-96172-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96172-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id v14-20020a170903238e00b001dbeb95bafbsi14637873plh.575.2024.03.07.12.16.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 12:16:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96172-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=c--e.de); spf=pass (google.com: domain of linux-kernel+bounces-96172-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96172-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CB3D82874FE for ; Thu, 7 Mar 2024 20:16:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7838B1386C0; Thu, 7 Mar 2024 20:16:14 +0000 (UTC) Received: from cae.in-ulm.de (cae.in-ulm.de [217.10.14.231]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66A581384A3; Thu, 7 Mar 2024 20:16:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.10.14.231 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709842573; cv=none; b=fIwrZj/N6R7OdhdbamGQbLo5bOQdWiPefJBAB9KcJOiI8dxwY1G12jV6TuTezuLs3Rw//uwqwcD4ET33xZ/f+xv7LhRlhW0A3bAHNa2kOENWYhtAd/KHruPc477AtsgkNASXpi4LbapVbOZk6OAZRO1qEM3oHchRosySLp+wdyY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709842573; c=relaxed/simple; bh=A4ojRm1yac8P8+7JjT9Co/kkOIRrumYEoOESGZHp/gA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EGlYyeYNP6Lw9YX3bwoWZNXnbIZUw9P45dBC5JBsrdE4U88CwUeFOqIlxhcdDTGLBkawoE2SAoMyULd4Q8n87S2pv3QFN8wXg5sna+ZJvdYKGyfST0CcMKP1LWegsBBVlOK+ac4pPiTR/sTPUsTXhGsu2eRpyGgta8jBCafu5DQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c--e.de; spf=pass smtp.mailfrom=c--e.de; arc=none smtp.client-ip=217.10.14.231 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c--e.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c--e.de Received: by cae.in-ulm.de (Postfix, from userid 1000) id 8CB3B14053E; Thu, 7 Mar 2024 21:16:00 +0100 (CET) Date: Thu, 7 Mar 2024 21:16:00 +0100 From: "Christian A. Ehrhardt" To: coverity-bot Cc: Jameson Thies , Hans de Goede , Fabrice Gasnier , Neil Armstrong , linux-usb@vger.kernel.org, Benson Leung , Saranya Gopal , Dmitry Baryshkov , Abhishek Pandit-Subedi , Prashant Malani , Heikki Krogerus , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Gustavo A. R. Silva" , linux-next@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: Coverity: ucsi_check_cable(): Null pointer dereferences Message-ID: References: <202403071134.7C7C077655@keescook> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202403071134.7C7C077655@keescook> Hi, On Thu, Mar 07, 2024 at 11:34:21AM -0800, coverity-bot wrote: > Hello! > > This is an experimental semi-automated report about issues detected by > Coverity from a scan of next-20240307 as part of the linux-next scan project: > https://scan.coverity.com/projects/linux-next-weekly-scan > > You're getting this email because you were associated with the identified > lines of code (noted below) that were touched by commits: > > Tue Mar 5 13:11:08 2024 +0000 > f896d5e8726c ("usb: typec: ucsi: Register SOP/SOP' Discover Identity Responses") > > Coverity reported the following: > > *** CID 1584245: Null pointer dereferences (FORWARD_NULL) > drivers/usb/typec/ucsi/ucsi.c:1136 in ucsi_check_cable() > 1130 } > 1131 > 1132 ret = ucsi_register_cable(con); > 1133 if (ret < 0) > 1134 return ret; > 1135 > vvv CID 1584245: Null pointer dereferences (FORWARD_NULL) > vvv Passing "con" to "ucsi_get_cable_identity", which dereferences null "con->cable". > 1136 ret = ucsi_get_cable_identity(con); > 1137 if (ret < 0) > 1138 return ret; > 1139 > 1140 ret = ucsi_register_plug(con); > 1141 if (ret < 0) > > If this is a false positive, please let us know so we can mark it as > such, or teach the Coverity rules to be smarter. If not, please make > sure fixes get into linux-next. :) For patches fixing this, please > include these lines (but double-check the "Fixes" first): This looks like a false positive to me. The code looks like this: if (con->cable) return 0; [ ... ] ret = ucsi_register_cable(con) if (ret < 0) return ret; ret = ucsi_get_cable_identity(con); [ ... ] From the con->cable check coverity concludes that con->cable is initially NULL. Later ucsi_register_cable() initializes con->cable if successful. Coverity seems to miss this and still thinks that con->cable is NULL. Then converity correctly notices that ucsi_get_cable_identity() dereferences con->cable and complains. regards Christian