Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 May 2016 21:05:15 -0700
From:      Jason Harmening <jason.harmening@gmail.com>
To:        Ravi Pokala <rpokala@mac.com>, "Jason A. Harmening" <jah@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r300258 - head/sys/dev/iicbus
Message-ID:  <573E8CFB.8090007@gmail.com>
In-Reply-To: <371B94E2-E906-4F9C-9A9B-A9D35CD93D21@panasas.com>
References:  <201605200303.u4K334pG019632@repo.freebsd.org> <371B94E2-E906-4F9C-9A9B-A9D35CD93D21@panasas.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--wdfkXCrMBbsV3tTt1XrLIdUCnou6BPrgo
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable



On 05/19/16 20:50, Ravi Pokala wrote:
> -----Original Message-----
> From: <owner-src-committers@freebsd.org> on behalf of "Jason A. Harmeni=
ng" <jah@FreeBSD.org>
> Date: 2016-05-19, Thursday at 20:03
> To: <src-committers@freebsd.org>, <svn-src-all@freebsd.org>, <svn-src-h=
ead@freebsd.org>
> Subject: svn commit: r300258 - head/sys/dev/iicbus
>=20
>> Author: jah
>> Date: Fri May 20 03:03:04 2016
>> New Revision: 300258
>> URL: https://svnweb.freebsd.org/changeset/base/300258
>>
>> Log:
>>  iic_rdwr_data->nmsgs is uint32_t, so limit the allowable number of me=
ssages to prevent memory exhaustion and short allocations on 32-bit syste=
ms. Since iicrdwr is intended to be a workalike of a Linux i2c-dev call, =
use the same limit of 42 that Linux uses.
>> =20
>>  Also check the return value of copyin(9) to prevent unnecessary alloc=
ation in the failure case.
>> =20
>>  ...
>> =20
>> 	error =3D copyin(d->msgs, buf, sizeof(*d->msgs) * d->nmsgs);
>> +	if (error !=3D 0) {
>> +		free(buf, M_IIC);
>> +		return (error);
>> +	}
>>
>=20
> Hi Jason,
>=20
> If I=E2=80=99m reading that right, it=E2=80=99s not preventing any allo=
cations, but it is preventing a leak. Is that correct?
>=20
> Thanks,
>=20
> Ravi (rpokala@)
>=20
>=20

Hi Ravi,

There shouldn't be a leak in here, but checking the result prevents
falling through the rest of the function, including the unnecessary
malloc of usrbufs right after this.  It also makes the error handling
clearer.

Thanks,
Jason


--wdfkXCrMBbsV3tTt1XrLIdUCnou6BPrgo
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQF8BAEBCgBmBQJXPoz8XxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRENkY3MTQyREU0MTU4MTgyRkZDNUU2ODVC
QjlGOEJGOTkyODQxRDFCAAoJELufi/mShB0b47oIAI/bEO3FBfBJzir97Td4AZ2W
veG1JMN+yLlnUX0FG8Ij+VOzqu2+vRhONPgp68zEIMyaPwLQS5eyTfWmowibRJbX
FM+DrulKhI/mNUZ9r2QluilB7PIrJtXwcpGZbVeu84dOfYWgDDbqfIwSlF8kyxLh
YDvkFeu86vZabocP9ovzt8Kjw1epJ0jcpVm/uK3BI6gsYvV7iQ7jJQDOXZCvYhlu
QbCkppO42SfzexgCLcyD+uXrVFiXddaCQp9g3E0OeSf408to4gBdwstpnN/EQMYT
Q4GWvd3P23RpBeAHOGxEIq1h5admLd+F7+c0/LYm0s0bxvtL6beqexFnmZuMKhE=
=xVDU
-----END PGP SIGNATURE-----

--wdfkXCrMBbsV3tTt1XrLIdUCnou6BPrgo--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?573E8CFB.8090007>