Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751858AbdGGKEc (ORCPT ); Fri, 7 Jul 2017 06:04:32 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:6456 "EHLO alexa-out-lv-02.qualcomm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750768AbdGGKE3 (ORCPT ); Fri, 7 Jul 2017 06:04:29 -0400 X-IronPort-AV: E=Sophos;i="5.40,322,1496127600"; d="scan'208";a="411874" X-IronPort-AV: E=McAfee;i="5800,7501,8583"; a="1382888915" X-MGA-submission: =?us-ascii?q?MDE5VHQ/5CKHQkwvjGypubP+lN8I8nUvWpxpcp?= =?us-ascii?q?j/jyVofZ0LlkupF8W0FOmLJXQ/JzUi+X/rhymAQlbrBakhpyJLlSDUxO?= =?us-ascii?q?gm/v81c2oJ0ewep5DWNd92ko0za1o6XvfyR0DS9iV32z+oSCj/Gdse+w?= =?us-ascii?q?rX?= From: Kalle Valo To: Erik Stromdahl CC: Geert Uytterhoeven , Arnd Bergmann , "ath10k@lists.infradead.org" , linux-wireless , "netdev@vger.kernel.org" , Linux Kernel Mailing List Subject: Re: ath10k: ret used but uninitialized Thread-Topic: ath10k: ret used but uninitialized Thread-Index: AQHS9whp4PtXL3F45UqCL+3Dc/PNhA== Date: Fri, 7 Jul 2017 10:04:24 +0000 Message-ID: <87bmowd0mh.fsf@kamboji.qca.qualcomm.com> References: In-Reply-To: (Erik Stromdahl's message of "Thu, 6 Jul 2017 22:01:57 +0200") Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.251.52.12] Content-Type: text/plain; charset="utf-8" Content-ID: <3A66E09684FF0242BCD94863EA28B1E8@qualcomm.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v67A4cK4014666 Content-Length: 2760 Lines: 85 Erik Stromdahl writes: >> With gcc 4.1.2: >> >> drivers/net/wireless/ath/ath10k/sdio.c: In function >> ‘ath10k_sdio_mbox_rxmsg_pending_handler’: >> drivers/net/wireless/ath/ath10k/sdio.c:676: warning: ‘ret’ may be used >> uninitialized in this function >> >>> + >>> + *done = true; >>> + >>> + /* Copy the lookahead obtained from the HTC register table into our >>> + * temp array as a start value. >>> + */ >>> + lookaheads[0] = msg_lookahead; >>> + >>> + timeout = jiffies + SDIO_MBOX_PROCESSING_TIMEOUT_HZ; >> >> Although very unlikely due to the long timeout, if the code is preempted here, >> and the loop below never entered, ret will indeed be uninitialized. >> >> It's unclear to me what the proper initialization would be, though, so >> that's why I didn't send a patch. >> > I think it would be best to use 0 as initial value of ret in this case. > This will make all other interrupts be processed in a normal way. > > Kalle: Should I create a new patch (initializing ret with zero)? Yes, please send a new patch fixing this. But I don't like that much with the style of initialising ret to zero, it tends to hide things. Instead my preference is something like below where the error handling is more explicit and easier to find where it's exactly failing. But that's just an example how I would try to solve it, it still lacks the handling of -ECANCEL etc. diff --git a/drivers/net/wireless/ath/ath10k/sdio.c b/drivers/net/wireless/ath/ath10k/sdio.c index 859ed870bd97..19a53e577932 100644 --- a/drivers/net/wireless/ath/ath10k/sdio.c +++ b/drivers/net/wireless/ath/ath10k/sdio.c @@ -689,8 +689,10 @@ static int ath10k_sdio_mbox_rxmsg_pending_handler(struct ath10k *ar, */ ret = ath10k_sdio_mbox_rx_alloc(ar, lookaheads, n_lookaheads); - if (ret) - break; + if (ret) { + ath10k_warn(ar, "failed to ....: %d", ret); + return ret; + } if (ar_sdio->n_rx_pkts >= 2) /* A recv bundle was detected, force IRQ status @@ -709,8 +711,10 @@ static int ath10k_sdio_mbox_rxmsg_pending_handler(struct ath10k *ar, lookaheads, &n_lookaheads); - if (!n_lookaheads || ret) - break; + if (!n_lookaheads || ret) { + ath10k_warn(ar, "failed to ...."); + return ret; + } /* For SYNCH processing, if we get here, we are running * through the loop again due to updated lookaheads. Set @@ -721,11 +725,7 @@ static int ath10k_sdio_mbox_rxmsg_pending_handler(struct ath10k *ar, *done = false; } - if (ret && (ret != -ECANCELED)) - ath10k_warn(ar, "failed to get pending recv messages: %d\n", - ret); - - return ret; + return 0; } static int ath10k_sdio_mbox_proc_dbg_intr(struct ath10k *ar) -- Kalle Valo