Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755365AbaDGNOI (ORCPT ); Mon, 7 Apr 2014 09:14:08 -0400 Received: from mail-vc0-f178.google.com ([209.85.220.178]:60892 "EHLO mail-vc0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754992AbaDGNOH (ORCPT ); Mon, 7 Apr 2014 09:14:07 -0400 MIME-Version: 1.0 In-Reply-To: <1396339273-15904-1-git-send-email-tlinder@codeaurora.org> References: <1396339273-15904-1-git-send-email-tlinder@codeaurora.org> Date: Mon, 7 Apr 2014 15:14:05 +0200 Message-ID: Subject: Re: [RFC/PATCH] mtd: ubi: Test return value of __wl_get_peb From: Richard Weinberger To: Tanya Brokhman Cc: Artem Bityutskiy , "linux-mtd@lists.infradead.org" , open list Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 1, 2014 at 10:01 AM, Tanya Brokhman wrote: > In case of an error (if there are not free PEB's for example), > __wl_get_peb will return a negative value. In order to prevent access > violation we need to test the returned value prior to using it later on. > > Signed-off-by: Tatyana Brokhman > > diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c > index 02317c1..457ead3 100644 > --- a/drivers/mtd/ubi/wl.c > +++ b/drivers/mtd/ubi/wl.c > @@ -684,6 +684,9 @@ int ubi_wl_get_peb(struct ubi_device *ubi) > peb = __wl_get_peb(ubi); > spin_unlock(&ubi->wl_lock); > > + if (peb < 0) > + return peb; > + > err = ubi_self_check_all_ff(ubi, peb, ubi->vid_hdr_aloffset, > ubi->peb_size - ubi->vid_hdr_aloffset); > if (err) { Acked-by: Richard Weinberger -- Thanks, //richard -- 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/