Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2039642imm; Sat, 13 Oct 2018 08:53:38 -0700 (PDT) X-Google-Smtp-Source: ACcGV610dln/By7EqBaGZ0GK5gF8lB8B4O00YkbWqS80pPPheiTMFUoF+t08ucGiqnAOrcsg6ka3 X-Received: by 2002:a17:902:6b06:: with SMTP id o6-v6mr9950407plk.6.1539446018808; Sat, 13 Oct 2018 08:53:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539446018; cv=none; d=google.com; s=arc-20160816; b=GkMvqCj2SYLflY37uhVJjjvW61pGp0jVLcE3LWjSHclxS5qdvLcXYk4FC19rpFGvjN /uXEaFuK4utVVG66bZx925MClTp9BRrFVe+H7TyQsMMMJWj9hfANipw4Iw1sMuYJcBeA Z3bdNNxtY2QkdQdseL8W2Pg58iXnX6D26q6UW7ZnukxA3VcKUEkW72+knvNwIw1Z0dAi 5MaR9wr6y0zb0baaWsPaZy/Bnj1IJO1Qrpx1fxg8uvy8ZkOHeT4NP7FD/ljBz2VHP75T v0HrESGKuyjzNx7EE/9WK9NBiMAWNbsjv2y4xwLKaE8Z5GT0eYkAYEbvhBvZH+LuvVcI jHjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=Ud6zg7iKlaxnAwCQcutn4DL52TU17MWC7H7GjCellEw=; b=orwOuqF+66Bdnr6RA7LHCJkCGWEX8OFX7tJ2V4VltuS0K0ZuIQGpF3yYYjpYucrTVx 9OqCSsPYaIs1v5HNNjsrzU76K1BkzCgL0gud9cVHYdAZcelFaPJts0SlXp+ueFzZEM3K 1dkshYfSwKEHw3eBwN7MPiHepkStj2yIURnTWl6zKlunacNGZT9HnGy4c5rewxxdbBej cUxcASpp4wdAIWl/aA7aj99TuBGUhPhDr1OjRC/cmMukxQIRT/aARCmYTwhfI4ImNJc8 vu99lk89ddSS7eQF8gf92XVAO4Egyrfak/NcNv3stmpdBmFitTmNAbhyUI+OaHduXTk4 rfvA== 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 d9-v6si4692927pgm.109.2018.10.13.08.53.23; Sat, 13 Oct 2018 08:53:38 -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 S1726703AbeJMXan (ORCPT + 99 others); Sat, 13 Oct 2018 19:30:43 -0400 Received: from elektron.elka.pw.edu.pl ([194.29.160.103]:49441 "EHLO elektron.elka.pw.edu.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726362AbeJMXan (ORCPT ); Sat, 13 Oct 2018 19:30:43 -0400 Received: from [172.19.1.1] (178235205188.warszawa.vectranet.pl [178.235.205.188]) (Authenticated sender: wzabolot@elektron.elka.pw.edu.pl) by elektron.elka.pw.edu.pl (Postfix) with ESMTPSA id 295A368B016; Sat, 13 Oct 2018 17:53:00 +0200 (CEST) Subject: Re: Bug introduced in the of_get_named_gpiod_flags function. To: Michal Simek , Linus Walleij , wzab@ise.pw.edu.pl, Randy Dunlap , Masahiro Yamada , "open list:GPIO SUBSYSTEM" Cc: "linux-kernel@vger.kernel.org" References: <90dbf770-5262-5128-e585-c44d086568f9@ise.pw.edu.pl> <5d33d03a-5d62-c8c8-c9cc-2ccbe1b464f2@xilinx.com> From: "wzabolot@elektron.elka.pw.edu.pl" Openpgp: preference=signencrypt Autocrypt: addr=wzabolot@elektron.elka.pw.edu.pl; prefer-encrypt=mutual; keydata= mQQNBFRVBfcBIADx6Hopt8KdGyDbCXQUZKa4JqFdIHy0k/njOq4S+TE7CrPzBtXwPFSHKqQu wm4VcFG8VPBDaMGFxgvLYkWQR/nDNT3gG+s5o42IbyLpH1r0CHMzNqMStdAWSzO/HSZIYGl6 FPcN5XkEVonDQY+61LyEY6Dkb8STI0/7lnFt6H9eaD6rPyA8COFtQcr7c2oyrEWBXUEIsUUT Xw52Z2VZkCgKpViryNxO6+aLCph3I26MkTcEysV+rc7BBRuVOHeUodSAuGdrsvTfR+aJN9Az XbWqsx0EcLJ0veLhL0tTnldzXuvd4wtqNh5FHfFa0uZt88CsBFppMQP5ayCG08IeOcCMksl/ sTggqBB+aBgRgj72dPRs5sdKEfeqGsFBLEEunTN6iyQx/b7SKu7+T4WBpNfh8e7A8sTT2+w+ RWImf93w3ypJORINn3DM9q8oDYx+xqIbEDniBGZQCcwEkuDQR3kIPUeoh3J4upFEcno2NlQ4 IlywHeMintnZRqf4ccWJ4gfZVWOOE+l91WyOd0JAMiMBNcGgAceSLF1TskRJGH7QHr4eZE63 zsv9lmENNVy59XdySERGdYacsVhnX+V4T13gC6ZekHVSdSbcJICxjbcBj1m41Rqbho0LLPrc uwno8M9WD0FJHf/2ld+PhrotD+EluFNy2885LNkgafHGrJVUO4yA10gHIS//QOPHtFdlE/yF yeVYIWsBwZEksgtZ2m4942ivc7bWnusHqzW7lJOf8nGU8KUC4PikiOAgBka3uQTYuaedWR18 SvEW6dYEgaIcX9jF+WDQ2gR4COA7BfJAjABTgrO3XxvGrhHtk9LiYlAZ45rITeIlgAvwyoBR x3ZioYER71AcZBJOHGHwIOJ930W9CfnHn+fTPLQZ1JU0zrOE9BJgYDfgfeLxngomWPBCMI1O 67BPyLyUS7FN/CbWaXpNR82tJYvESHgEwVYwossi7yZcUXK+9sggb0eMFqAgyeeN6I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s1EqcxTg6O4iu4rZ4NaRFBFhDzJP1JIp84jsUgXdh CYv5UIXBzed+FcMrAkpY12gzPDSvNyj4NHeX+TWTjWME8k3ez1N8wMcT7WP96stVjEcOPLb4 towcOHZHSAtCZNKAgggsx2xAYFquSdezgXeWLHXpPPuEiqQg1JKsAzXrU7fLrpI9cbR4knqx nEtk6/jzPFkKNw4S1v0l4lPX2JAJiM3w6fx43NrAEzhN84AhEoRo9Yvne/mfI8xHCUfYo3Rc mKs39mAf6ufYmkvfAfAT3cO3/sMn/EIyEUmbxL/YZNHGIv688g36Ww+LzrNNTtgEmtEpqeiB jkrWfEulM1oc3KSrtb9UO579ebaf61NHu7QLzRS7 Message-ID: Date: Sat, 13 Oct 2018 17:53:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <5d33d03a-5d62-c8c8-c9cc-2ccbe1b464f2@xilinx.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: pl-PL Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/12/18 10:54 AM, Michal Simek wrote: > Hi, > > On 11.10.2018 10:27, Linus Walleij wrote: >> Hi Wojciech, >> >> (Thanks also Randy for forwarding this!) >> >> On Wed, Oct 10, 2018 at 6:32 PM wzab wrote: >> >>> The function of_get_named_gpiod_flags in older versions of the kernel >>> (up to 4.7.10 - https://elixir.bootlin.com/linux/v4.7.10/source/drivers/gpio/gpiolib-of.c#L75 ) >>> contained an important workaround: >>> >>> /* .of_xlate might decide to not fill in the flags, so clear it. */if (flags) >>> *flags = 0; Unfortunately, newer kernels do not contain it. Therefore if the >>> "xlat" function in the gpiochip driver does not set flags, (like e.g. >>> the Xilinx AXI GPIO driver: https://github.com/Xilinx/linux-xlnx/blob/c2ba891326bb472da59b6a2da29aca218d337687/drivers/gpio/gpio-xilinx.c#L262 ) >>> the random, unitialized value from the stack in of_find_gpio >>> ( https://elixir.bootlin.com/linux/v4.18.13/source/drivers/gpio/gpiolib-of.c#L228 ) >>> is used, which results in random settings of e.g., OPEN DRAIN or OPEN SOURCE mode. >>> >>> I have also reported the problem in the Xilinx forum: >>> https://forums.xilinx.com/t5/Embedded-Linux/Bug-in-of-get-named-gpiod-flags-function-in-the-kernel-random/td-p/897695 >> It seems the commit removing this is: >> >> commit 762c2e46c0591d207289105c8718e4adf29b2b34 >> "gpio: of: remove of_gpiochip_and_xlate() and struct gg_data" >> >> But I honestly don't see a problem with it. >> >> You are referencing an out-of-tree driver. Use the in-tree gpio-xilinx.c >> that does not do any custom xlate and you will be fine. >> >> I looked over the driver doing custom flag translation in the kernel tree, >> and they all set flags, so this is not a problem in the upstream kernel. > There was an attempt to sync up xilinx internal gpio driver with > mainline by someone else but not sure what's the status. > If you have issue with xilinx internal patch please talk to us. > If the problem is with mainline please use this mailing list. > > Thanks, > Michal The question is, if there may be any other in-tree GPIO controller driver that does not initialize those flags? Anyway the current situation is somehow dangerous. Maybe the best solution would be to initialize the automatic variable in the of_find_gpio? With best regards, Wojtek -- Wojciech M Zabolotny, PhD Institute of Electronic Systems Faculty of Electronics and Information Technology Warsaw University of Technology