Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965211AbcKXLcU (ORCPT ); Thu, 24 Nov 2016 06:32:20 -0500 Received: from mail-wm0-f42.google.com ([74.125.82.42]:37713 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964851AbcKXLcS (ORCPT ); Thu, 24 Nov 2016 06:32:18 -0500 MIME-Version: 1.0 In-Reply-To: <5323.1479986239@warthog.procyon.org.uk> References: <147997746306.9316.227351186233378585.stgit@warthog.procyon.org.uk> <147997747766.9316.11606802798600210253.stgit@warthog.procyon.org.uk> <5323.1479986239@warthog.procyon.org.uk> From: Andrey Ryabinin Date: Thu, 24 Nov 2016 14:22:58 +0300 Message-ID: Subject: Re: [PATCH 2/2] MPI: Fix mpi_powm() when exponent is 0 and the result has no limbs To: David Howells Cc: jmorris@namei.org, Dmitry Kasatkin , LKML , stable@vger.kernel.org, linux-security-module@vger.kernel.org, keyrings@vger.kernel.org, linux-ima-devel@lists.sourceforge.net Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 449 Lines: 20 2016-11-24 14:17 GMT+03:00 David Howells : > David Howells wrote: > >> + if (!rp) { >> + if (mpi_resize(res, 1) < 0) > > This is better done with RESIZE_IF_NEEDED(). > mpi_resize() is equal to RESIZE_IF_NEEDED(), it also checks for allocated space: int mpi_resize(MPI a, unsigned nlimbs) { .... if (nlimbs <= a->alloced) return 0; /* no need to do it */ > David