Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754090AbbGIUtg (ORCPT ); Thu, 9 Jul 2015 16:49:36 -0400 Received: from mout.web.de ([212.227.15.3]:61416 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932107AbbGIUtT (ORCPT ); Thu, 9 Jul 2015 16:49:19 -0400 Subject: Re: i2c-HID: Delete unnecessary checks before the function call "gpiod_put" To: Benjamin Tissoires , Jiri Kosina , Mika Westerberg References: <5307CAA2.8060406@users.sourceforge.net> <530A086E.8010901@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> <559D8874.7090407@users.sourceforge.net> Cc: linux-input , Linux Kernel Mailing List , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring X-Enigmail-Draft-Status: N1110 Message-ID: <559EDE3D.1030409@users.sourceforge.net> Date: Thu, 9 Jul 2015 22:49:01 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:J7c9B6QGIxEaRYXn7f8MlkBQzNGF4JJSxe7+F8RUElhLb2Xd3mi y1nukx5jtqnlqY8GfEm98pl+1jkihJ/tIETA/JvTdQTkDflE7YdXSmsKlNSYkEW5ICsmSxG 1PdZejPckrkuvb2mKqyAa0B1q4OybKcGrKmKi0ONb+qGoP1drDSU56V3bL4HAQCV993vP2p S/jruwl/zNcfvjwGyJCiA== X-UI-Out-Filterresults: notjunk:1;V01:K0:EjU7XR7wyFU=:JJopsiaPTcu7lnx641c4xc ewVSUSxhvJDGmL7UsSPImTSbsPT8+89Iwj41BpIs15qUCvxFO8o4yzf6lIyw6GgAW70DCCdtx bTLJG3FKLLbxGuNdPFvdlIBc8P7iknse9rGYrtsPfrKSDpVO/ZZ9TVlrGtykI0wVX7h33sh1E k4ufksiADgZgSjOKKCdzN7JJTISZ+tDzGBmek8Slg+QbtK8miPlstctkfa6FVnLjJEHEtyCW4 2iOpBuEDO1QYsDhphcyfC4SBAM/KBo8hZUsAV+pzoj3JLOjrIusyzV8eESwtCMoztVEvzgH42 WUMO5lklASANxuoYNQA1eVsdmbCv04cwlqVYVYuZjHJFaxXisVQfOaDEpoDvr9ls8ipp66xNA M++jm8CXXBgbZve+XgZAVcPA6TIx5Mq4ye7jfMgRMqs1rx5MoJUayFlc68fGgje3mDYysVMXb kccVEuMp+ESSPWZhFChcmGZKFniwPHnn05+/Rh/JdktV8u2mzFcGxAUThB941Lqr9pQIFp54y c6ADCcWb20c9rkoXZcD5+b1fSgj6HMajH+GMA1FJiWcq+w+pFjUJsI7rYA4Cf85DN1r6bB+GI MP9IHU7KdcpJWzZRCZv7f99jqc/i9WC40EZ1DsetxzHK7vE/oxncshsMS9Dh1V3xSKoAcCwZ5 aaFDHvq40DTLTYFJrSc3O0AhrxFjoGjm4bTwjiFstVurk7QDUdRxSW3TJxIc4D88rRiw= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1653 Lines: 41 >>> The gpiod_put() function performs also input parameter validation >>> by forwarding its single input pointer to the gpiod_free() function. >>> Thus the test around the calls is not needed. >>> >>> This issue was detected by using the Coccinelle software. >>> >>> Signed-off-by: Markus Elfring >> >> As Dan correctly pointed out, this is not as straightforward as it might >> seem on a firsr sight, because there is a WARN_ON() that might start >> triggering in case of !ihid->desc. >> >> Adding Benjamin. I am not applying this without his Ack. >> > > I think the gpiod case is the exception rather than the common rule > (most i2c-hid device we saw until recently were using irqs, not > gpios). So if I understand correctly, removing the check on ihid->desc > would raise a warning for most devices. This is IMO not a good thing, > so I would say NACK. > > Mika might have a different opinion though. The proposed update candidates are contained in the source file "drivers/hid/i2c-hid/i2c-hid.c" from Linux next-20150708. * i2c_hid_remove() function: Can it be tolerated here that the pointer "ihid->desc" might be eventually null? * i2c_hid_probe() function: Is this implementation structured in such a way that a pointer for valid data will be usually passed for "ihid->desc" if the statements after the jump label "err" will be reached? Regards, Markus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/