Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751554AbbEFPp0 (ORCPT ); Wed, 6 May 2015 11:45:26 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:58847 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751488AbbEFPpV (ORCPT ); Wed, 6 May 2015 11:45:21 -0400 Message-ID: <1430927107.11698.17.camel@decadent.org.uk> Subject: Re: [PATCH 3.2 108/221] spi: dw-mid: avoid potential NULL dereference From: Ben Hutchings To: Luis Henriques , Andy Shevchenko Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, akpm@linux-foundation.org, Mark Brown Date: Wed, 06 May 2015 16:45:07 +0100 In-Reply-To: <20150506102502.GA1691@ares.olymp> References: <20150506102502.GA1691@ares.olymp> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-HMkB4q34rJkU4eNNBFas" X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 X-SA-Exim-Connect-IP: 192.168.4.249 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3801 Lines: 108 --=-HMkB4q34rJkU4eNNBFas Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2015-05-06 at 11:25 +0100, Luis Henriques wrote: > On Tue, May 05, 2015 at 02:16:39AM +0100, Ben Hutchings wrote: > > 3.2.69-rc1 review patch. If anyone has any objections, please let me k= now. > >=20 > > ------------------ > >=20 > > From: Andy Shevchenko > >=20 > > commit c9dafb27c84412fe4b17c3b94cc4ffeef5df1833 upstream. > >=20 > > When DMA descriptor allocation fails we should not try to assign any fi= elds in > > the bad descriptor. The patch adds the necessary checks for that. > >=20 > > Fixes: 7063c0d942a1 (spi/dw_spi: add DMA support) > > Signed-off-by: Andy Shevchenko > > Signed-off-by: Mark Brown > > [bwh: Backported to 3.2: adjust context] > > Signed-off-by: Ben Hutchings > > --- > > drivers/spi/spi-dw-mid.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > >=20 > > --- a/drivers/spi/spi-dw-mid.c > > +++ b/drivers/spi/spi-dw-mid.c > > @@ -155,6 +155,9 @@ static int mid_spi_dma_transfer(struct d > > 1, > > DMA_TO_DEVICE, > > DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_DEST_UNMAP); > > + if (!txdesc) > > + return NULL; > > + >=20 > This backport doesn't look right to me as the function returns an int, > not a pointer. OTOH, it seems like this return value is not checked > anywhere, which is why I dropped this patch in the 3.16 kernel. In mainline the DMA descriptor setup is split out into the dw_spi_dma_prepare_tx() and dw_spi_dma_prepare_rx() functions. If they return NULL then mid_spi_dma_transfer() doesn't attempt to submit adescriptor to the respective channel, but it still returns 0. So not only is this backport pretty useless, but so is the upstream 'fix'. Ben. > Cheers, > -- > Lu=C3=ADs >=20 > > txdesc->callback =3D dw_spi_dma_done; > > txdesc->callback_param =3D dws; > > =20 > > @@ -177,6 +180,9 @@ static int mid_spi_dma_transfer(struct d > > 1, > > DMA_FROM_DEVICE, > > DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_DEST_UNMAP); > > + if (!rxdesc) > > + return NULL; > > + > > rxdesc->callback =3D dw_spi_dma_done; > > rxdesc->callback_param =3D dws; > > =20 > >=20 > > -- > > To unsubscribe from this list: send the line "unsubscribe stable" in > > the body of a message to majordomo@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html --=20 Ben Hutchings If at first you don't succeed, you're doing about average. --=-HMkB4q34rJkU4eNNBFas Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIVAwUAVUo3COe/yOyVhhEJAQod4A/7BQm1bcCXn1t/WL/st+yzAH9amrRcK9F5 A9o+HEHM/9fnZ+ZjWvBJzRbwV1s4ZJ3qQRMov5D7tuio/NTrbxpUieFx7N4sjjaO ny4qhyUTEsnn05ehwGgaTGWbh58qWl/1h+p1PCvWHbI9/vIgrIwbD8pdtRj2io1e 1wHsTnRt4bSKxP34u/ughHpYlbaLt5daANfRBvvNsO0mBojzRBz4qZkz1SVAei0k xEMjMwGk7Uyj8C1XOVOC+vHiM+hqfMA4Ltewj92y+yGHf6CX7qdOujRnLoduIFJz Ts8sxIDpe18dPOeCUij1HP7VH6UVRJV0oR0Nsj3vPdQW+KKkNJ63Or7gUmy5B0nU S0SotcESuNGKwug12aohzCZVU/8kerrTj2wTGKE5IdZ2L6zUiTQCBEVCUvsryNSC ptPG4TwIakRfkkNUEMOkpyChaWOm+bZ4/N01gT2aGUsITSCj4/i43nI/bpW/13Dl UHT1uGBPMIuoqwE+604TOFxvj9KRRukr7ZwJPV7sGkqEsumVukWcr6+Q/TWki4xn RnfuvBpk1EjqvaLZfu+usCsPlz2qjq9ZYt47SBJKen+ma9lD3Z6xfl026DcQ2yDE j3f26FRWf2vAY9OooEFtWxx05/HHCXfhxzMDSeENUMJTAycbILpLoM9PyFXKYRXM Cc8a3BH5Wxc= =aacM -----END PGP SIGNATURE----- --=-HMkB4q34rJkU4eNNBFas-- -- 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/