blk: fix overflow in queue_discard_max_hw_show
diff mbox

Message ID 20160217141436.4666.99213.stgit@localhost.localdomain
State New
Headers show

Commit Message

Alan Cox Feb. 17, 2016, 2:15 p.m. UTC
We get this right for queue_discard_max_show but not max_hw_show. Follow the
same pattern as queue_discard_max_show instead so that we don't truncate.

Signed-off-by: Alan Cox <alan@linux.intel.com>
---
 block/blk-sysfs.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Jens Axboe Feb. 17, 2016, 5:20 p.m. UTC | #1
On 02/17/2016 07:15 AM, Alan wrote:
> We get this right for queue_discard_max_show but not max_hw_show. Follow the
> same pattern as queue_discard_max_show instead so that we don't truncate.
>
> Signed-off-by: Alan Cox <alan@linux.intel.com>
> ---
>   block/blk-sysfs.c |    5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index e140cc4..dd93763 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -147,10 +147,9 @@ static ssize_t queue_discard_granularity_show(struct request_queue *q, char *pag
>
>   static ssize_t queue_discard_max_hw_show(struct request_queue *q, char *page)
>   {
> -	unsigned long long val;
>
> -	val = q->limits.max_hw_discard_sectors << 9;
> -	return sprintf(page, "%llu\n", val);
> +	return sprintf(page, "%llu\n",
> +		(unsigned long long)q->limits.max_hw_discard_sectors << 9);
>   }

Thanks Alan, applied.

Patch
diff mbox

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index e140cc4..dd93763 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -147,10 +147,9 @@  static ssize_t queue_discard_granularity_show(struct request_queue *q, char *pag
 
 static ssize_t queue_discard_max_hw_show(struct request_queue *q, char *page)
 {
-	unsigned long long val;
 
-	val = q->limits.max_hw_discard_sectors << 9;
-	return sprintf(page, "%llu\n", val);
+	return sprintf(page, "%llu\n",
+		(unsigned long long)q->limits.max_hw_discard_sectors << 9);
 }
 
 static ssize_t queue_discard_max_show(struct request_queue *q, char *page)