Message ID | 1443103227-25612-5-git-send-email-a.hajda@samsung.com (mailing list archive) |
---|---|
State | Changes Requested, archived |
Delegated to: | Laurent Pinchart |
Headers |
Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from <linux-media-owner@vger.kernel.org>) id 1Zf7Au-00037x-JO; Thu, 24 Sep 2015 16:07:04 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.76/mailfrontend-6) with esmtp id 1Zf7As-0005nZ-5F; Thu, 24 Sep 2015 16:07:04 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756477AbbIXOBl (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Thu, 24 Sep 2015 10:01:41 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:8833 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755871AbbIXOBM (ORCPT <rfc822;linux-media@vger.kernel.org>); Thu, 24 Sep 2015 10:01:12 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NV6008M4PLYG170@mailout3.w1.samsung.com>; Thu, 24 Sep 2015 15:01:10 +0100 (BST) X-AuditID: cbfec7f4-f79c56d0000012ee-57-56040226e92a Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 36.2A.04846.62204065; Thu, 24 Sep 2015 15:01:10 +0100 (BST) Received: from AMDC1061.digital.local ([106.116.147.88]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NV600IK6PLM8670@eusync4.samsung.com>; Thu, 24 Sep 2015 15:01:10 +0100 (BST) From: Andrzej Hajda <a.hajda@samsung.com> To: linux-kernel@vger.kernel.org Cc: Andrzej Hajda <a.hajda@samsung.com>, Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>, Marek Szyprowski <m.szyprowski@samsung.com>, Laurent Pinchart <laurent.pinchart@ideasonboard.com>, Mauro Carvalho Chehab <mchehab@osg.samsung.com>, linux-media@vger.kernel.org Subject: [PATCH 04/19] v4l: omap3isp: fix handling platform_get_irq result Date: Thu, 24 Sep 2015 16:00:12 +0200 Message-id: <1443103227-25612-5-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1443103227-25612-1-git-send-email-a.hajda@samsung.com> References: <1443103227-25612-1-git-send-email-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnluLIzCtJLcpLzFFi42I5/e/4NV01JpYwgwXvFCxurTvHarFxxnpW i86JS9gtLu+aw2bRs2Erq8XaI3fZLVY/q3Bg95jdMZPVY0v/XXaPvi2rGD0+b5ILYInisklJ zcksSy3St0vgyvj1cSNrwUnOih1zP7I0MH5m72Lk5JAQMJG41fCGCcIWk7hwbz1bFyMXh5DA UkaJ67M+MEM4TUwSV+7dZQGpYhPQlPi7+SYbiC0ioCCxufcZK0gRs8A0JomzF/sYQRLCAl4S B3Z3gY1lEVCV+LVzBVicV8BZYuG2e4wQ6+QkTh6bzApicwq4SLydugmsXgio5sSRWWwTGHkX MDKsYhRNLU0uKE5KzzXUK07MLS7NS9dLzs/dxAgJpi87GBcfszrEKMDBqMTD66DFHCbEmlhW XJl7iFGCg1lJhJfjPVCINyWxsiq1KD++qDQntfgQozQHi5I479xd70OEBNITS1KzU1MLUotg skwcnFINjMs7NgZr/do696BddnquA4+18b1uP1fWphfPs4+W/po4d3l7wdaS+MS7a3T2J8T7 KrNf6b6nFf3WPv2ZZXV21xONg5Hhsw5GW5su2STXtsmZ90RnpOqeyc7TuO8q1HXuuaXGrvzf 3i4iZUdAZHq1uyF/IOuMxZzscg3Sfo5eEz+elThZqHFDiaU4I9FQi7moOBEAYv8euyICAAA= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2015.9.24.140016 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' HTML_NO_HTTP 0.1, MULTIPLE_RCPTS 0.1, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1300_1399 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, NO_URI_HTTPS 0, REFERENCES 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_HTML 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __MULTIPLE_URI_TEXT 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_IN_BODY 0, __URI_NO_WWW 0, __URI_NS ' |
Commit Message
Andrzej Hajda
Sept. 24, 2015, 2 p.m. UTC
The function can return negative value.
The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].
[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
Hi,
To avoid problems with too many mail recipients I have sent whole
patchset only to LKML. Anyway patches have no dependencies.
Regards
Andrzej
---
drivers/media/platform/omap3isp/isp.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Comments
Hi Andrzej, Thank you for the patch. On Thursday 24 September 2015 16:00:12 Andrzej Hajda wrote: > The function can return negative value. > > The problem has been detected using proposed semantic patch > scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1]. > > [1]: http://permalink.gmane.org/gmane.linux.kernel/2046107 > > Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> > --- > Hi, > > To avoid problems with too many mail recipients I have sent whole > patchset only to LKML. Anyway patches have no dependencies. > > Regards > Andrzej > --- > drivers/media/platform/omap3isp/isp.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/platform/omap3isp/isp.c > b/drivers/media/platform/omap3isp/isp.c index 56e683b..df9d2c2 100644 > --- a/drivers/media/platform/omap3isp/isp.c > +++ b/drivers/media/platform/omap3isp/isp.c > @@ -2442,12 +2442,13 @@ static int isp_probe(struct platform_device *pdev) > } > > /* Interrupt */ > - isp->irq_num = platform_get_irq(pdev, 0); > - if (isp->irq_num <= 0) { > + ret = platform_get_irq(pdev, 0); > + if (ret <= 0) { Looking at platform_get_irq() all error values are negative. You could just test for ret < 0 here, and remove the ret = -ENODEV assignment below to keep the error code returned by platform_get_irq(). If you're fine with that modification there's no need to resubmit, just let me know and I'll fix it when applying it to my tree. > dev_err(isp->dev, "No IRQ resource\n"); > ret = -ENODEV; > goto error_iommu; > } > + isp->irq_num = ret; > > if (devm_request_irq(isp->dev, isp->irq_num, isp_isr, IRQF_SHARED, > "OMAP3 ISP", isp)) {
On 11/09/2015 09:16 PM, Laurent Pinchart wrote: > Hi Andrzej, > > Thank you for the patch. > > On Thursday 24 September 2015 16:00:12 Andrzej Hajda wrote: >> The function can return negative value. >> >> The problem has been detected using proposed semantic patch >> scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1]. >> >> [1]: http://permalink.gmane.org/gmane.linux.kernel/2046107 >> >> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> >> --- >> Hi, >> >> To avoid problems with too many mail recipients I have sent whole >> patchset only to LKML. Anyway patches have no dependencies. >> >> Regards >> Andrzej >> --- >> drivers/media/platform/omap3isp/isp.c | 5 +++-- >> 1 file changed, 3 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/media/platform/omap3isp/isp.c >> b/drivers/media/platform/omap3isp/isp.c index 56e683b..df9d2c2 100644 >> --- a/drivers/media/platform/omap3isp/isp.c >> +++ b/drivers/media/platform/omap3isp/isp.c >> @@ -2442,12 +2442,13 @@ static int isp_probe(struct platform_device *pdev) >> } >> >> /* Interrupt */ >> - isp->irq_num = platform_get_irq(pdev, 0); >> - if (isp->irq_num <= 0) { >> + ret = platform_get_irq(pdev, 0); >> + if (ret <= 0) { > Looking at platform_get_irq() all error values are negative. You could just > test for ret < 0 here, and remove the ret = -ENODEV assignment below to keep > the error code returned by platform_get_irq(). > > If you're fine with that modification there's no need to resubmit, just let me > know and I'll fix it when applying it to my tree. I left it as before, as it was not related to the patch. Additionally I have lurked little bit inside platform_get_irq and it looks little bit scary to me: platform_get_irq returns value of of_irq_get if ret >= 0, of_irq_get calls of_irq_parse_one which can return 0, in such case irq_create_of_mapping value is returned which is unsigned int and evaluates to 0 in case of failures. I am not sure if above scenario can ever occur, but the code looks so messy to me, that I gave up :) Anyway if you are sure about your change I am OK with it also :) Regards Andrzej > >> dev_err(isp->dev, "No IRQ resource\n"); >> ret = -ENODEV; >> goto error_iommu; >> } >> + isp->irq_num = ret; >> >> if (devm_request_irq(isp->dev, isp->irq_num, isp_isr, IRQF_SHARED, >> "OMAP3 ISP", isp)) { -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Andrzej, On Tuesday 10 November 2015 07:48:54 Andrzej Hajda wrote: > On 11/09/2015 09:16 PM, Laurent Pinchart wrote: > > On Thursday 24 September 2015 16:00:12 Andrzej Hajda wrote: > >> The function can return negative value. > >> > >> The problem has been detected using proposed semantic patch > >> scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1]. > >> > >> [1]: http://permalink.gmane.org/gmane.linux.kernel/2046107 > >> > >> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> > >> --- > >> Hi, > >> > >> To avoid problems with too many mail recipients I have sent whole > >> patchset only to LKML. Anyway patches have no dependencies. > >> > >> drivers/media/platform/omap3isp/isp.c | 5 +++-- > >> 1 file changed, 3 insertions(+), 2 deletions(-) > >> > >> diff --git a/drivers/media/platform/omap3isp/isp.c > >> b/drivers/media/platform/omap3isp/isp.c index 56e683b..df9d2c2 100644 > >> --- a/drivers/media/platform/omap3isp/isp.c > >> +++ b/drivers/media/platform/omap3isp/isp.c > >> @@ -2442,12 +2442,13 @@ static int isp_probe(struct platform_device > >> *pdev) > >> } > >> > >> /* Interrupt */ > >> - isp->irq_num = platform_get_irq(pdev, 0); > >> - if (isp->irq_num <= 0) { > >> + ret = platform_get_irq(pdev, 0); > >> + if (ret <= 0) { > > > > Looking at platform_get_irq() all error values are negative. You could > > just test for ret < 0 here, and remove the ret = -ENODEV assignment below > > to keep the error code returned by platform_get_irq(). > > > > If you're fine with that modification there's no need to resubmit, just > > let me know and I'll fix it when applying it to my tree. > > I left it as before, as it was not related to the patch. Additionally I have > lurked little bit inside platform_get_irq and it looks little bit scary to > me: platform_get_irq returns value of of_irq_get if ret >= 0, > of_irq_get calls of_irq_parse_one which can return 0, > in such case irq_create_of_mapping value is returned which is unsigned int > and evaluates to 0 in case of failures. > I am not sure if above scenario can ever occur, but the code looks so messy > to me, that I gave up :) > > Anyway if you are sure about your change I am OK with it also :) You're right, that's indeed an issue. It looks like a 0 irq is valid or invalid depending on who you ask. NO_IRQ is defined differently depending on the architecture :-/ I'll thus keep your version of the patch. Nonetheless, the core issue should be fixed. Do you feel adventurous ? :-) > >> dev_err(isp->dev, "No IRQ resource\n"); > >> ret = -ENODEV; > >> goto error_iommu; > >> > >> } > >> > >> + isp->irq_num = ret; > >> > >> if (devm_request_irq(isp->dev, isp->irq_num, isp_isr, IRQF_SHARED, > >> > >> "OMAP3 ISP", isp)) {
On 11/10/2015 09:53 AM, Laurent Pinchart wrote: > Hi Andrzej, > > On Tuesday 10 November 2015 07:48:54 Andrzej Hajda wrote: >> On 11/09/2015 09:16 PM, Laurent Pinchart wrote: >>> On Thursday 24 September 2015 16:00:12 Andrzej Hajda wrote: >>>> The function can return negative value. >>>> >>>> The problem has been detected using proposed semantic patch >>>> scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1]. >>>> >>>> [1]: http://permalink.gmane.org/gmane.linux.kernel/2046107 >>>> >>>> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> >>>> --- >>>> Hi, >>>> >>>> To avoid problems with too many mail recipients I have sent whole >>>> patchset only to LKML. Anyway patches have no dependencies. >>>> >>>> drivers/media/platform/omap3isp/isp.c | 5 +++-- >>>> 1 file changed, 3 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/drivers/media/platform/omap3isp/isp.c >>>> b/drivers/media/platform/omap3isp/isp.c index 56e683b..df9d2c2 100644 >>>> --- a/drivers/media/platform/omap3isp/isp.c >>>> +++ b/drivers/media/platform/omap3isp/isp.c >>>> @@ -2442,12 +2442,13 @@ static int isp_probe(struct platform_device >>>> *pdev) >>>> } >>>> >>>> /* Interrupt */ >>>> - isp->irq_num = platform_get_irq(pdev, 0); >>>> - if (isp->irq_num <= 0) { >>>> + ret = platform_get_irq(pdev, 0); >>>> + if (ret <= 0) { >>> Looking at platform_get_irq() all error values are negative. You could >>> just test for ret < 0 here, and remove the ret = -ENODEV assignment below >>> to keep the error code returned by platform_get_irq(). >>> >>> If you're fine with that modification there's no need to resubmit, just >>> let me know and I'll fix it when applying it to my tree. >> I left it as before, as it was not related to the patch. Additionally I have >> lurked little bit inside platform_get_irq and it looks little bit scary to >> me: platform_get_irq returns value of of_irq_get if ret >= 0, >> of_irq_get calls of_irq_parse_one which can return 0, >> in such case irq_create_of_mapping value is returned which is unsigned int >> and evaluates to 0 in case of failures. >> I am not sure if above scenario can ever occur, but the code looks so messy >> to me, that I gave up :) >> >> Anyway if you are sure about your change I am OK with it also :) > You're right, that's indeed an issue. It looks like a 0 irq is valid or > invalid depending on who you ask. NO_IRQ is defined differently depending on > the architecture :-/ I'll thus keep your version of the patch. > > Nonetheless, the core issue should be fixed. Do you feel adventurous ? :-) Currently I am busy with other tasks, so I will be happy if somebody will take care of it :), if not I will return to it if time permits. Regards Andrzej > >>>> dev_err(isp->dev, "No IRQ resource\n"); >>>> ret = -ENODEV; >>>> goto error_iommu; >>>> >>>> } >>>> >>>> + isp->irq_num = ret; >>>> >>>> if (devm_request_irq(isp->dev, isp->irq_num, isp_isr, IRQF_SHARED, >>>> >>>> "OMAP3 ISP", isp)) { -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index 56e683b..df9d2c2 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -2442,12 +2442,13 @@ static int isp_probe(struct platform_device *pdev) } /* Interrupt */ - isp->irq_num = platform_get_irq(pdev, 0); - if (isp->irq_num <= 0) { + ret = platform_get_irq(pdev, 0); + if (ret <= 0) { dev_err(isp->dev, "No IRQ resource\n"); ret = -ENODEV; goto error_iommu; } + isp->irq_num = ret; if (devm_request_irq(isp->dev, isp->irq_num, isp_isr, IRQF_SHARED, "OMAP3 ISP", isp)) {