From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753541AbdEJPat (ORCPT ); Wed, 10 May 2017 11:30:49 -0400 Received: from imap0.codethink.co.uk ([185.43.218.159]:35731 "EHLO imap0.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752755AbdEJPar (ORCPT ); Wed, 10 May 2017 11:30:47 -0400 Message-ID: <1494430234.3965.37.camel@codethink.co.uk> Subject: Re: [PATCH 4.4 10/43] net: cavium: liquidio: Avoid dma_unmap_single on uninitialized ndata From: Ben Hutchings To: Greg Kroah-Hartman , Raghu Vatsavayi , Florian Fainelli Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, "David S. Miller" , Julia Lawall Date: Wed, 10 May 2017 16:30:34 +0100 In-Reply-To: <20170501212559.952803810@linuxfoundation.org> References: <20170501212559.546911128@linuxfoundation.org> <20170501212559.952803810@linuxfoundation.org> Organization: Codethink Ltd. Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2017-05-01 at 14:27 -0700, Greg Kroah-Hartman wrote: > 4.4-stable review patch. If anyone has any objections, please let me know. > > ------------------ > > From: Florian Fainelli > > commit 8e6ce7ebeb34f0992f56de078c3744fb383657fa upstream. > > The label lio_xmit_failed is used 3 times through liquidio_xmit() but it > always makes a call to dma_unmap_single() using potentially > uninitialized variables from "ndata" variable. Out of the 3 gotos, 2 run > after ndata has been initialized, and had a prior dma_map_single() call. > > Fix this by adding a new error label: lio_xmit_dma_failed which does > this dma_unmap_single() and then processed with the lio_xmit_failed > fallthrough. > > Fixes: f21fb3ed364bb ("Add support of Cavium Liquidio ethernet adapters") > Reported-by: coverity (CID 1309740) > Signed-off-by: Florian Fainelli > Signed-off-by: David S. Miller > Cc: Julia Lawall > Signed-off-by: Greg Kroah-Hartman This is not a complete fix: > --- > drivers/net/ethernet/cavium/liquidio/lio_main.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > --- a/drivers/net/ethernet/cavium/liquidio/lio_main.c > +++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c > @@ -2823,7 +2823,7 @@ static int liquidio_xmit(struct sk_buff > if (!g) { > netif_info(lio, tx_err, lio->netdev, > "Transmit scatter gather: glist null!\n"); > - goto lio_xmit_failed; > + goto lio_xmit_dma_failed; > } > > cmdsetup.s.gather = 1; [...] This goto should not have been changed, as no DMA mapping has been attempted at this point in the function. This seems to have been fixed upstream by commit 6a885b60dad2 "liquidio: Introduce new octeon2/3 header". I leave it to you to work out how it should be fixed in 4.4-stable. Ben. -- Ben Hutchings Software Developer, Codethink Ltd.