Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10880967ybi; Thu, 25 Jul 2019 06:30:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBawKOMNpsgR79r8N7LuAx0KHpInP0DFLqb+pPkrga8LLwN+S4QVXn8MroXNw4oLNCrxqa X-Received: by 2002:a63:db45:: with SMTP id x5mr73824693pgi.293.1564061407286; Thu, 25 Jul 2019 06:30:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564061407; cv=none; d=google.com; s=arc-20160816; b=Sbp+QOVcT5bzsr4K1w4J/VDo8GCp+VuCIlJmtEChvBcN2gRCOtwPSZIzrTQhD4Rhsw qRX+dL+LgVOSrWb0Oh4ABKf0hnuQWF99cv9IK2MsPDBbDN0ghGXGJE+eirkJM7qUH79G H8zoO2AbP4w2K8bmhHHmTp1dkRXEYxVqqvFrJbxESdvNhN7Qr4BUynCorX/65DdLoggG Izf2AxyUfEe2qO45LV/L3IqBVgel4PxO3KZ9oT+q/Y51MvfA6u25kvL3+H/XqPjZGbQz wge1lWu2szm6ri7CPKcu8eoYeoCBCO/T9TLgvDfNFStPMARhzrQcPC6S176WCSAYhcDv C7ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=mQt8ygjArqnKFvtgRxz8Ixcgg5kZ7uEN2MnSq2JY0Yo=; b=jxMFs0WouigJtVBDhmC+xAQNl4yQ99HrWkY6g4e5zhzi5UR5kG1cetRad2mgtCwGy2 W1l3unVqVm5+fWDj5aj6ZXMSkv2kaeHxfnMDVgeSlvSJ8VYCOQjuHxflRgskgiags8Nb zDnQRqvq5uCNJF5LA69avbjlUh0iLy7FQl4M9yyKPueNra5+6YupsqWTGpQPZsFqGA90 fO//dDN5mupjQMCAE6bL9+mfRZgYQTJmFNYO++S6b1R6RAopcvgUCOFBAvd3P67Q0tax F9LaqWkTKFpEgZ6HkHpUcQwiroyfxFr1avF0OFdE7ZwJVCLmu61HaR0VwkqupJG56keq ZDmQ== ARC-Authentication-Results: i=1; mx.google.com; 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 cb11si17888307plb.100.2019.07.25.06.29.52; Thu, 25 Jul 2019 06:30:07 -0700 (PDT) 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; 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 S1728133AbfGYKo4 (ORCPT + 99 others); Thu, 25 Jul 2019 06:44:56 -0400 Received: from gofer.mess.org ([88.97.38.141]:41021 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726513AbfGYKoz (ORCPT ); Thu, 25 Jul 2019 06:44:55 -0400 Received: by gofer.mess.org (Postfix, from userid 1000) id EA01460474; Thu, 25 Jul 2019 11:44:53 +0100 (BST) Date: Thu, 25 Jul 2019 11:44:53 +0100 From: Sean Young To: Wolfram Sang Cc: Wolfram Sang , linux-i2c@vger.kernel.org, Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] media: ir-kbd-i2c: prevent potential NULL pointer access Message-ID: <20190725104453.5kqusisyg44zbbcy@gofer.mess.org> References: <20190722172632.4402-1-wsa+renesas@sang-engineering.com> <20190722172632.4402-2-wsa+renesas@sang-engineering.com> <20190725051202.o47mz4unbn63z6uk@gofer.mess.org> <20190725075538.GB1323@kunai> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190725075538.GB1323@kunai> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Wolfram, On Thu, Jul 25, 2019 at 09:55:38AM +0200, Wolfram Sang wrote: > Hi Sean, > > thanks for the review! > > On Thu, Jul 25, 2019 at 06:12:02AM +0100, Sean Young wrote: > > On Mon, Jul 22, 2019 at 07:26:31PM +0200, Wolfram Sang wrote: > > > i2c_new_dummy() can fail returning a NULL pointer. The code does not > > > bail out in this case and the returned pointer is blindly used. > > > > I don't see how. The existing code tries to set up the tx part; if > > i2c_new_dummy() return NULL then the rcdev is registered without tx, > > and tx_c is never used. > > Yes, you are totally right. I missed that the send_block function is > also only called iff zilog_init succeeded. Thanks for the heads up and > sorry for the noise. Not at all, thank you for the patch. > > > Convert > > > to devm_i2c_new_dummy_device() which returns an ERR_PTR and also bail > > > out when failing the validity check. > > > > Possibly I was being overly cautious with not bailing out if tx can't > > be registered; moving to devm is probably a good idea. However the > > commit message is misleading, because the existing code has no > > NULL pointer access. > > Yep, I will resend with a proper commit message. Technically, there is > no need to bail out anymore because there is no NULL pointer access. My > tendency is now to not bail out and keep the old behaviour (registering > without tx). What do you think? Since I write this code I've got pretty much every model with this zilog transmitter/receiver, and they all work fine, including different firmware versions. If there is a problem it would be nice to hear about it, and not silently swallow the error. I think. Thanks, Sean