Received: by 10.213.65.68 with SMTP id h4csp2408253imn; Mon, 2 Apr 2018 07:05:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx49l3wmI5pHhJgTnfZ1gjYochS7JsRux6lSBR0PBfjtmj37zwu9nSeGfE5PnYK0fcQ8LwwBs X-Received: by 2002:a17:902:6bc1:: with SMTP id m1-v6mr9867790plt.366.1522677904162; Mon, 02 Apr 2018 07:05:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522677904; cv=none; d=google.com; s=arc-20160816; b=rSV+CoX8Oy3aYG5V4Bgc6Wj/igU1b79oZHgyzXdQHqMq2Vqk4E4LDbnSMpwgX7BG/B BuwGgXww9PoDBPANYQPe3djfHvhTJC67ZRSRNiXwef2RSvfx2qNGGSCspOPGNkFqx+3H AEcD477tz/h1hFf4P9Ef12XHMKE4kjKKJ2pJU97mmW2ejN8SZQU8R1YJuBuO8mUoocTA krRDvdEHk3uSMxazhqvUqHPqBS2B6PrmpJKY6OtFapdXdsMqoovwY1cHaE4WJ/AcVxz2 F5YWmvioj8av1YXi9ofVfbmDE8vOI6HCsUL/7KBv2mgWLUI7VwmTUOeCxHKlvq775E29 G+HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=xKQB6tR+NFOLeasiqEcPdY2SMnT6T9oU98m7G4kkHaY=; b=tQc8l6ve0PJ6x/eUlnqAxxYETF0Su9w82/Q8cdC0NttBtxOv07edeABetGAiHZbuKL gXZG2j9YTM+UsC73Rg1vhRRywbe8aROWumtwnlHpvBL//De1MYY/dCidn/I1+e+oclpJ vibsqwVjt8TahKXGWceJLCLJQYeT6WznNbNE6H9FpiNovfF1N5jINL9Tneft8y90E5Ze H7eGTEkyLW5IeC5VErrZo84KloogpUvM5dfcqtzVEMW33G5e/YwYcGRe17Qm9oaitR8s ChBVDso8WrgX/Gc1ewiLDovxA9QwtroS2fB6iRPa1zb1LM+mYRkxdA/Bqj1HRPZFdA9D seBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f11si271133pgn.420.2018.04.02.07.04.50; Mon, 02 Apr 2018 07:05:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752023AbeDBODi (ORCPT + 99 others); Mon, 2 Apr 2018 10:03:38 -0400 Received: from smtp01.smtpout.orange.fr ([80.12.242.123]:34837 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751852AbeDBODd (ORCPT ); Mon, 2 Apr 2018 10:03:33 -0400 Received: from ubuntu-CJ.home ([86.244.119.222]) by mwinf5d48 with ME id VS3V1x00N4nzehS03S3V5K; Mon, 02 Apr 2018 16:03:30 +0200 X-ME-Helo: ubuntu-CJ.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 02 Apr 2018 16:03:30 +0200 X-ME-IP: 86.244.119.222 From: Christophe JAILLET To: dmitry.torokhov@gmail.com, benjamin.tissoires@redhat.com, gregkh@linuxfoundation.org Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] Input: synaptics-rmi4 - Fix an unchecked out of memory error path Date: Mon, 2 Apr 2018 16:03:27 +0200 Message-Id: <20180402140327.7715-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When extending the rmi_spi buffers, we must check that no out of memory error occurs, otherwise we may access data above the currently allocated memory. Propagate the error code returned by 'rmi_spi_manage_pools()' instead. Signed-off-by: Christophe JAILLET --- drivers/input/rmi4/rmi_spi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/input/rmi4/rmi_spi.c b/drivers/input/rmi4/rmi_spi.c index 76edbf2c1bce..082defc329a8 100644 --- a/drivers/input/rmi4/rmi_spi.c +++ b/drivers/input/rmi4/rmi_spi.c @@ -147,8 +147,11 @@ static int rmi_spi_xfer(struct rmi_spi_xport *rmi_spi, if (len > RMI_SPI_XFER_SIZE_LIMIT) return -EINVAL; - if (rmi_spi->xfer_buf_size < len) - rmi_spi_manage_pools(rmi_spi, len); + if (rmi_spi->xfer_buf_size < len) { + ret = rmi_spi_manage_pools(rmi_spi, len); + if (ret < 0) + return ret; + } if (addr == 0) /* -- 2.14.1