From patchwork Tue Jun 25 11:40:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Knauf X-Patchwork-Id: 11015363 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9058C13AF for ; Tue, 25 Jun 2019 11:47:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7866628478 for ; Tue, 25 Jun 2019 11:47:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CB46285B3; Tue, 25 Jun 2019 11:47:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B49A628478 for ; Tue, 25 Jun 2019 11:47:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726996AbfFYLrl (ORCPT ); Tue, 25 Jun 2019 07:47:41 -0400 Received: from mailout2n.rrzn.uni-hannover.de ([130.75.2.113]:56312 "EHLO mailout2n.rrzn.uni-hannover.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728527AbfFYLrl (ORCPT ); Tue, 25 Jun 2019 07:47:41 -0400 X-Greylist: delayed 309 seconds by postgrey-1.27 at vger.kernel.org; Tue, 25 Jun 2019 07:47:40 EDT Received: from lab-pc01.sra.uni-hannover.de (lab.sra.uni-hannover.de [130.75.33.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mailout2n.rrzn.uni-hannover.de (Postfix) with ESMTPSA id 267C51F3F6; Tue, 25 Jun 2019 13:42:30 +0200 (CEST) From: Florian Knauf To: Jens Axboe Cc: linux-kernel@i4.cs.fau.de, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Florian Knauf , Christian Ewert Subject: [PATCH] drivers/block/loop: Remove deprecated function, range check for max_loop Date: Tue, 25 Jun 2019 13:40:56 +0200 Message-Id: <20190625114056.8706-1-florian.knauf@stud.uni-hannover.de> X-Mailer: git-send-email 2.17.1 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch removes the deprecated simple_strtol function from the option parsing logic in the loopback device driver. It also introduces a range check for the max_loop parameter to ensure that negative and out-of-range values (that cannot be represented by int max_loop) are ignored. Signed-off-by: Florian Knauf Signed-off-by: Christian Ewert --- drivers/block/loop.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 102d79575895..acdd028ed486 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -2289,7 +2289,17 @@ module_exit(loop_exit); #ifndef MODULE static int __init max_loop_setup(char *str) { - max_loop = simple_strtol(str, NULL, 0); + long max_loop_long = 0; + + /* + * Range check for max_loop: negative values and values not + * representable by int are ignored. + */ + if (kstrtol(str, 0, &max_loop_long) == 0 && + max_loop_long >= 0 && + max_loop_long <= INT_MAX) + max_loop = (int) max_loop_long; + return 1; }