From patchwork Thu Oct 25 15:29:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 10656067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F102B13A9 for ; Thu, 25 Oct 2018 15:35:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE4792BD1A for ; Thu, 25 Oct 2018 15:35:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0F412BD5E; Thu, 25 Oct 2018 15:35:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 773542BD1A for ; Thu, 25 Oct 2018 15:35:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=NrUDxMYLkyg5HPJonb+JuSxGDm5o24A0GKSFyklBhZY=; b=gIPewPsT/1O8WJ9RBPCw8ODGzW GILyywTpIKZt+wEqFL8ScdQihvDDcwX6YW5W/3ZkouomaEz4nzgODZzq7bkVW8fuRuP1c28WOBAx2 a3X6zHbjHmyPb18xAcEwsL91xBXPeqD+sfeMopAJo0p1VEMKTbDCh0P/nKp1y36ofTOCR+dvgN6hK JdAKxnhkJPP9LDZMms3ogdQm7+NS71j9z64/EDqKzMp4DFace5/1ctwTYZEKMj3xNOBTO3Tom/BLH 59C/qyNypStFV8v2nzuFKYtS1ridG1jEFWlgmGSb69kF6EPlD+aQqTYDhjBIWgH22pvo45Zr49RoF pJRKp7TA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gFhfr-0003tV-EC; Thu, 25 Oct 2018 15:35:51 +0000 Received: from mout.kundenserver.de ([212.227.126.130]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gFhae-0000Lj-TN; Thu, 25 Oct 2018 15:30:39 +0000 Received: from localhost.localdomain ([37.4.249.153]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M5fZ4-1gE5122KBm-007FAs; Thu, 25 Oct 2018 17:30:06 +0200 Received: from localhost.localdomain ([37.4.249.153]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M5fZ4-1gE5122KBm-007FAs; Thu, 25 Oct 2018 17:30:06 +0200 From: Stefan Wahren To: Eric Anholt , gregkh@linuxfoundation.org, Dave Stevenson Subject: [PATCH RFC 01/11] staging: bcm2835-camera: Abort probe if there is no camera Date: Thu, 25 Oct 2018 17:29:25 +0200 Message-Id: <1540481375-15952-2-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540481375-15952-1-git-send-email-stefan.wahren@i2se.com> References: <1540481375-15952-1-git-send-email-stefan.wahren@i2se.com> X-Provags-ID: V03:K1:dCzZlVGOCeNOZaUHjMGojvlwLXAOy+bBPiUsScqjgKIjyF4bZ2n fTXGmEQwpFL7jVdjJ1Tt/6GWfp9EXq464h5IksjQtvjXzMY+E8O4jQmHfcRhfgclbZ0QsXp +QyqZt1Hi1Zov7OF33PHPSgoWSTKQPxigf6k9poC8VJCR+zfTDvY8yBJEFdjjTgwvyR/Zuo DrJX7U4zgIx+sVivwFxLg== X-UI-Out-Filterresults: notjunk:1;V01:K0:i+6qK/+eezw=:zHpe+2lC0eBuqbOCeLBMRs OLK2u2N1DuBkU16PQw4axU3u9xFcSRxHdsHmgcEk2ZM7VyT1yX05cu4oibgMckd4sc5V93Yo2 uGJ+QtrBZ64w7LwRcaB6vibyi+aYWgnR24t5G2K90+g9ZpOARA8bSdstLzC+stdzQgLEmIcpf pmzX11g2PmmScD+VlfdHqsKfrRmTkY+aZaGFVw1tV7C6lmuruBW5fPbn7W3tRN1dVuKfTHl1g jxKzV9Xavic8CVyxH2Ed0j/rFWibEDA0OOF57Noe2qM4thcoWXVGWanSYihfEJjulQTwA+uWx yhZyD1cartFIMGNibv25CDJE6Yiw7cbvOVyZRrjjGuW7t2TqeSI43fXN7JI40DwoR4uI5yDpI 0DNauNjL3jDcv7cHYAZuu3X/sGnafiJLrUI/vTMPNJfJDXtgLHkKSiAWfyFQevKqbZbs/Wnsg FPqQQRyDCSxBZ83ou3taSI/6GCVI352484NjMO1hxC1Nxd3bhA9H3Oal/cZMJ3FZB7+y03rW2 cF8CTEOeafDA/x+X2qEfHao1RTxLlLriV6HtNQ5Sa7cMbysnvMlNqHIQw23mxOnGkvCbmHu2B ZBjq2PFINdn0x4pydcpFzGpkRDAxov/3sLXxD3RDLK+xzJU/xvYUL08ISo3kwlTwzQz052/yj sqcSBUKOqtvCX9IknBICrw7N95dTj1Kl9ljHYGBtxiPJ3SCQiK7aD8Ebp132zueF8o2Q= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181025_083029_359138_0A882FDB X-CRM114-Status: GOOD ( 12.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, Stefan Wahren , linux-arm-kernel@lists.infradead.org, tiwai@suse.de, mikebrady@eircom.net, pbrobinson@gmail.com, nsaenzjulienne@suse.de, linux-rpi-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Abort the probing of the camera driver in case there isn't a camera actually connected to the Raspberry Pi. This solution also avoids a NULL ptr dereference of mmal instance on driver unload. Fixes: 7b3ad5abf027 ("staging: Import the BCM2835 MMAL-based V4L2 camera driver.") Signed-off-by: Stefan Wahren Tested-by: Peter Robinson --- drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index c04bdf0..d6fbef7 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -1841,6 +1841,12 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) num_cameras = get_num_cameras(instance, resolutions, MAX_BCM2835_CAMERAS); + + if (num_cameras < 1) { + ret = -ENODEV; + goto cleanup_mmal; + } + if (num_cameras > MAX_BCM2835_CAMERAS) num_cameras = MAX_BCM2835_CAMERAS; @@ -1940,6 +1946,9 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) pr_info("%s: error %d while loading driver\n", BM2835_MMAL_MODULE_NAME, ret); +cleanup_mmal: + vchiq_mmal_finalise(instance); + return ret; }