Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3657613imm; Mon, 15 Oct 2018 01:45:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV60hDr+r/C8qOSn+Z6jUSIKDsiMRggssKpWwDb69Hv76lDpz8uouOJHGRcbKaT+lP5nk4vcX X-Received: by 2002:a63:d52:: with SMTP id 18-v6mr15453249pgn.107.1539593148902; Mon, 15 Oct 2018 01:45:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539593148; cv=none; d=google.com; s=arc-20160816; b=rqUN2I7iVZEbNO3/gC8nPtOnWtEvfinqLU+jhiIy0tAb1QDK12gU1gubl4o2NI+QZB Edp5fPAl5U3DGjZh1NX1zaxMnY7q7h4xmuBXiBjGjOIIzThgUyAc62/eFaL1BvTT5KOi /OdnpvtwP81wKhnq7JaYHu9rnn0kzuyTrfqAUWM7XF8E7S6e8o9vYL71EWGTgkndUK/n GXCrSiCmr0WO+Y/Ag7AfHiPNykUplavSvidev6CeSmAODb0zvj5DEW6bCuTC3caEkfHq OOZLEYaPTE7yb0I+uyDNYSSeoVZboTc8/Di9J3cwae+sdA2CDCTuSDoJw+c+A/U1cRTx hzAA== 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:dkim-signature; bh=ufuzhKYnq8uqJos4sIyvko/QKM/XU/Y2YboVN29rboY=; b=tsrwJ/GJVj0YA0ixduMBiudGokmn5bDtgz7KSDBJ7c4XiqrsIr+HQoE+mMfgzBqBh6 5hLmUeaZtNdCDmYIBJlcCvkR0qa90M7sn9YYruM4sBwQQClqbGei931WhcjUBYGuPwib OaJALWVglOw8iOZ/6RxuZMlabTgYnPPSBam2mkLvpUym54iVyGMe7opTqdF2vEVMjzqn tkv1aPg3ICAcKmQG2oy5Vovv58jx75d7Qdj5PJVEYCX30s71e3zg9PFks2/5gASeDO7s UejWK27WJ0BSYSgbzyhm/f1M7LkdBjkYJeQ91KiP2fW8NtQ+e3Mvx+UJr0HqqaICRAS5 2j9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Wxb+eNMS; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u30-v6si9374335pgk.293.2018.10.15.01.45.32; Mon, 15 Oct 2018 01:45:48 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Wxb+eNMS; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726585AbeJOQ31 (ORCPT + 99 others); Mon, 15 Oct 2018 12:29:27 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44197 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726319AbeJOQ31 (ORCPT ); Mon, 15 Oct 2018 12:29:27 -0400 Received: by mail-wr1-f67.google.com with SMTP id 63-v6so20235549wra.11; Mon, 15 Oct 2018 01:45:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ufuzhKYnq8uqJos4sIyvko/QKM/XU/Y2YboVN29rboY=; b=Wxb+eNMSNuZOxzwANU1mB2LTJ88Ui0glmRXIh/0e5WR8GROXU5i+A/mM7xAPaH2WXU wVITEvoQmbRwP7fbxnFH4vqlD6H8T0LHfagoM1hyTwgCnD0l9WXfaDqJCGqoBULHvVBD G2Sc0iF2ci7IIcrHDkvmz+lDpFBG7Lj3CRFKlDBhiOcdhYZ1pGZzp6+wgjPvb7vJO73R JIm0oDQ1fVW+IAN6h+v02GhX0NXweI6PJiIN4nQpstIkw/d4kfz+R2B7hJ8AKQgHuRud 6mhaJu9tM3Yi2cK1zDvRD8JC8hWv7gGu8Z7R20Q6gouDgSDG1ETataBdyE8uxj6Z1QgP boqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ufuzhKYnq8uqJos4sIyvko/QKM/XU/Y2YboVN29rboY=; b=gRMvzIwdmpzVcxvHoXqCRCnJzyEhqr3KZSD83HfeNSozjriW3AMyiiXQErqHYLVhQC TM9deqXZS6OoZxhHegH9Osv7PRPZrnEYlpa7JK2tKIh7DA4YUgrEvvIgdtJlfAPxze3Y N8APFTfYnAQCyQLx7n1Gx54ydaqzNadLHCJyMa8zvXVzN1o6Ljgp4ir6KdnW9aduqvAh BdZCjxfvQadiLKccPX0JyePf7zTTIO1IRxdzdElTFCWclHPgeEIlBRjxo0P8Cpxh+GC7 p6RkIzT4TX4lPGzRpklm2fDYcNXUh15S2I2w1ajZtL4QGmlLzSuFYA6Qm8IkukmISZEb eFAg== X-Gm-Message-State: ABuFfogAvUZXzsLXy9oLL3qJplGrXabB4qTzMP2CY1wj8Wi92gNjPVdy bBcCQIW+Bj4SkCXRJMDeArjO64Kh X-Received: by 2002:a5d:60c3:: with SMTP id x3-v6mr14160998wrt.193.1539593107710; Mon, 15 Oct 2018 01:45:07 -0700 (PDT) Received: from localhost (pD9E5106D.dip0.t-ipconnect.de. [217.229.16.109]) by smtp.gmail.com with ESMTPSA id i15-v6sm7945382wro.58.2018.10.15.01.45.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Oct 2018 01:45:07 -0700 (PDT) Date: Mon, 15 Oct 2018 10:45:05 +0200 From: Thierry Reding To: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= Cc: =?utf-8?B?Vm9rw6HEjQ==?= Michal , Mark Rutland , "devicetree@vger.kernel.org" , "linux-pwm@vger.kernel.org" , Lukasz Majewski , "linux-kernel@vger.kernel.org" , Rob Herring , "kernel@pengutronix.de" , Fabio Estevam , Lothar =?utf-8?Q?Wa=C3=9Fmann?= Subject: Re: =?utf-8?B?W1JDRsKgUEFUQ0gsdjIsMi8y?= =?utf-8?Q?=5D?= pwm: imx: Configure output to GPIO in disabled state Message-ID: <20181015084505.GA12357@ulmo> References: <1539163920-9442-3-git-send-email-michal.vokac@ysoft.com> <20181012085720.GA9451@taurus.defre.kleine-koenig.org> <20181012160854.hmgpokxgsrqdzobx@pengutronix.de> <20181014202457.dohwgz3frgcpdpy6@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="sdtB3X0nJg68CQEu" Content-Disposition: inline In-Reply-To: <20181014202457.dohwgz3frgcpdpy6@pengutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --sdtB3X0nJg68CQEu Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Oct 14, 2018 at 10:24:57PM +0200, Uwe Kleine-K=C3=B6nig wrote: > Hello, >=20 > On Fri, Oct 12, 2018 at 06:08:54PM +0200, Uwe Kleine-K=C3=B6nig wrote: > > > >> + if (PTR_ERR(imx_chip->pwm_gpiod) =3D=3D -EPROBE_DEFER) { > > > >=20 > > > > You must not use PTR_ERR on a value that might not contain an error > > > > pointer. > > >=20 > > > OK, thank you for valuable info. > > > So it seems like the I2C folks are in troubles as well: > > >=20 > > > https://elixir.bootlin.com/linux/latest/source/drivers/i2c/busses/i2= c-imx.c#L996 > >=20 > > correct. I cannot find this documented though. >=20 > I found in LDD3[1], chapter 11 on page 295: >=20 > If you need the actual error code, it can be extracted with: >=20 > long PTR_ERR(const void *ptr); >=20 > You should use PTR_ERR only on a value for which IS_ERR returns a true > value; any other value is a valid pointer. >=20 > That is probably where I have my claim from. There is no further > explanation though, so I'll post a patch adding a comment to the > definition of PTR_ERR to find out if there is a relevant reason. Michal's code above does an implicit IS_ERR() by comparing to an actual error code. It's certainly true that PTR_ERR() on any pointer and then using that value can be risky because it may not actually be an error. So if you go and unconditionally print that error code even if it isn't an error but a valid pointer, you've leaked a kernel address. However, it's perfectly safe to use PTR_ERR(ptr) =3D=3D -EPROBE_DEFER (or for any other error code for that matter). Thierry --sdtB3X0nJg68CQEu Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAlvEU48ACgkQ3SOs138+ s6Gzqw//T+d8Wb41k3KDCT7WKo0TzK1p/AyL95o2ZS6lV2/+dd0DemSNRHykSY3s otrx+vwMpgEhMCA9m9n40Nw0hkmTTDXO3b1ppvLcq0dDArI+wjFbDJfcIsKegx70 90b9ccfTB84TYtcf4bRWtIO7DypS668OQw8VFbbxZ9bBp/+4CNbuhIZyw3brmK/a YSocK6ZuT3vauWO25LoIawz5WADU7RHl5mSl26ywUxKQ4zKe02RGUIH6qoB3jxmH heWsXt5C5Yrftn7ns7xvIZT7iufNA2eTW2FsEBQPer7dtflI9RkseTabouJf/VKD huryBYFmM2NjhcuzohnaPTNCp2txDDc8PFCyra0v4iiwgfwvhnIQYHTjFpiA3q6y mnhukrI9jX0dw4u3pbz5va8HOnwoWejRJKiWVWMmHsQPXscIC86PYDI90LYPimsk 4l2KpQUwOIrI3m/yC+E7g/AnYSxl3ZSW+0JrOP1NRlgZD9qxODjlwENndxeNdRdi 8OJdrmKLD36rc4TWMNAq3A33S68gKafAz85fh2eraeNvo3EgcN08zezPlAhHhIfb x2agre7MWxhiXolwD7Rbj6f5DaZAwpYtCXzhCcBAmjo1zoXCAcvb9cfRbiEyhB48 xGHF3lAyUxH+nFJ6unkqubdxMZz17jweaXvZ+6QsrCqnQdcrl4w= =lOQ2 -----END PGP SIGNATURE----- --sdtB3X0nJg68CQEu--