From patchwork Mon Jan 24 12:24:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 12722018 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1BD74C433EF for ; Mon, 24 Jan 2022 12:26:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 23C1B10EAF3; Mon, 24 Jan 2022 12:26:55 +0000 (UTC) Received: from mx0b-00069f02.pphosted.com (unknown [205.220.177.32]) by gabe.freedesktop.org (Postfix) with ESMTPS id C09ED10EAF1; Mon, 24 Jan 2022 12:26:53 +0000 (UTC) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20OAYF5U007774; Mon, 24 Jan 2022 12:24:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : content-type : mime-version; s=corp-2021-07-09; bh=xXuSl9Fccf9PP9wpw8nU35jHHiZCk3E5xTDQzAJmkR0=; b=pQMIrEd+4ndy3D0cAzMtLhUv41JOjRwmme4M94LN/a/gviMouGLhTKwgyFr8voiB3MYe Lu7fIW/rytwTlCAUFfV7BLmxf4tNjBQjiaBh1UE+83JWmAzyUjfy+95Oc/LdYeGkCgo2 S2NPN5GBB0so3oCx1nEcpPvl7/tbHLB5d4edrmSAm57ac2Vx8NjMzqpgbSgyCP2Fa/D1 GfgdLuqw+5RzrMC1Ibmh+6NvuM99sxXwB0t0vdC3sRJj4vKbxxWTRHipn7tDIhep8wrG ik6jndBl+zwTgCeug/ETmfy3A++C1gtMJt5sLh1fHxr0vUFauPrYAs3nPEedian0xA39 7g== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3dr8bdkx3x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jan 2022 12:24:33 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 20OCGhUl180220; Mon, 24 Jan 2022 12:24:32 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2171.outbound.protection.outlook.com [104.47.59.171]) by aserp3020.oracle.com with ESMTP id 3dr9r3v0t5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jan 2022 12:24:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OcL5BuRafh8oxYPEtpB+igpaABg616BDVc3R12yQakPmCIHvWcBEmVGBQk517i5aLg+kW1/SUkou5r3hASm0qIqasWTnxmrg96ExKoYg9o8bKqnlBDAW4N5anZ/ZjTvRgXrZsQ6Q9FOVQMt6NLW9D30v02bO0ZscFcGbC0EKqGde08QxOHJrxdsxtigsFalFwHF0dglgQTC1Fz3XUkJFPwBq5MVfXYPDds1QRudlLOgXNRoNwMhTVHYm9nfwimoeU44moihpkDtwt8Z+YNaREljZQoObiWU34xQRe5RpktlY9UehHfwVGEfiKxaeCk+N4asR4PKlNNCARNy1ZPoarA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xXuSl9Fccf9PP9wpw8nU35jHHiZCk3E5xTDQzAJmkR0=; b=A9qcdugeBhh3Nkbu7Huq8BIlcoChG4yhpD7N3eEYYdLtH7yw+M57vIyrU9bZ0b1oXOMGx8qfEY1/GLRZfNUSsxSFUpwG8a3lQsf0hWMlo8BZzqamINfpNktQPH8lVIEjBAXn+i3dtb4nfhCzC8SYt0xqQbILMOi6hzZdZoZr3mND1hQWEuoZutGcdxoeAhQqEz0qDmb48cDYm+xYX+BqFioTDZ6bK5kjRhxrosFxh2BPRBv09YuBEwsCfyaIN+0AOCNw4N2cClgO9p5RjVa/t0pepp9ZMmpFLsx++Zl7W16pK+P6vRMBTBe1vSc9ZJOUTvLzK//zMSQFEjzf1QzKfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xXuSl9Fccf9PP9wpw8nU35jHHiZCk3E5xTDQzAJmkR0=; b=Kg+sKG+xznyIZhCs91/fsVjx1iasceqn0ax3bTxtT2VVUmHJgUR/4SlCiOIzUC0i4INkRBbHKs/Gffjpk8vbHPtiUgq+cV4NfUOEUA3J6y+mPpozgJwpzfyyxsRF+pTgCcek2ONavGw8kfXS7B9z6UnrBSwXIXnFmhcZox8WRyo= Received: from MWHPR1001MB2365.namprd10.prod.outlook.com (2603:10b6:301:2d::28) by CY4PR10MB1734.namprd10.prod.outlook.com (2603:10b6:910:8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.12; Mon, 24 Jan 2022 12:24:30 +0000 Received: from MWHPR1001MB2365.namprd10.prod.outlook.com ([fe80::c13b:5812:a403:6d96]) by MWHPR1001MB2365.namprd10.prod.outlook.com ([fe80::c13b:5812:a403:6d96%6]) with mapi id 15.20.4909.017; Mon, 24 Jan 2022 12:24:30 +0000 Date: Mon, 24 Jan 2022 15:24:09 +0300 From: Dan Carpenter To: Jani Nikula , Daniel Vetter Message-ID: <20220124122409.GA31673@kili> Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.10.1 (2018-07-13) X-ClientProxiedBy: ZR0P278CA0198.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:44::12) To MWHPR1001MB2365.namprd10.prod.outlook.com (2603:10b6:301:2d::28) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e0519f3e-982a-4068-dc21-08d9df347886 X-MS-TrafficTypeDiagnostic: CY4PR10MB1734:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2733; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LeUdMKU2MZidwhmhQN+XjOH6+hXl6X1h5T3BF0saaWg9Y3Ck+Op7zHI+0s/x/b/0S+Euv094C25cE5q1zk/p6KF94/aPAsbDPJx2J2D0ArZCupU2HxYj4XEM8giM0cN8YIhzd83eiSVlWYSX0S+OBiwCd3CIP0tphVu+g6LrGXHM4mc00yPjS1FQLQbSkzUzf1N1m0+qmVyduaOTRb0ljv4bWySEi4IN+zLqHa1jUbialhkn28devT5xZweTS0vu6JHyi1/bVxE2Q0SrlY9gHZuWtfv4ovcLEn29mQCcfDXYrQ2l7YvqGBC1HGcwaG0wY20QhmNL4uEUMhrsYbu7rShtxY0KPFKbpbSgjGPKedJDbvhzTwVrSYx3YbxmNzJqN57t9sTc39Y6QeksUw5U/2k8cpHH0bs/RxtGt9k/OgTHpIx6kV9sNX540Y4U0kWL4v7FO5rthi1BHZZfTnS9SNmdJ6HLKARtIkHvF2gc6wtCXW5fnjEqAZgITbhsjbDFhbkWJ2yRnsh3WKV4TcXPe19IxaIAo7UOx/aycB+BVCIjR0D0yiLvacM1w5jSx4ZTIj64p5VgH2R6LsgYIMqj7E0F5vc7QDuiy2XSnVDnHS8tZp1xAhf71mALtY8DOlQiQb9UJbte9oTto/ElT/2SRtdmlI6NHyFzt8YrShtF6knsA7i0nHMVkkbItQsP1zahXD2oZCCRjEkBfymZ3H3yhA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2365.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(7916004)(366004)(6486002)(2906002)(26005)(6506007)(316002)(186003)(52116002)(6666004)(33656002)(4326008)(66476007)(508600001)(38100700002)(38350700002)(66946007)(86362001)(66556008)(7416002)(1076003)(8676002)(8936002)(44832011)(83380400001)(33716001)(5660300002)(54906003)(9686003)(110136005)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OmfXZwI3qxbp/8a7egz4ZC0zH3CqM8uxI7ISxg/9eBpxL1tfJcgiUYWCwCVPvQkQmWXCfCi/vnRlBgtChR1oPDyG+uWS1rzmS/yhOYrrtOkLT6JaYT9HDxXQtMMPrAo13O3rGhYrTEPa+LbniEHOV9GesFJp936W3w84UbS1+c2G9KnU0VJzjRSr7Htte+qK3SGHXEoep7RlVd2gCDs2NiprcT/ozuPVWW3NmCGcQuT/zZvmDJx8AkoIhbLE/9Wfrd7848VdpYZcK9ETqB++Rbhb8zP7SZ5/wnrnRqh9aDiF2STKQgiEV7lwdCG8kfjYPVar96odUSG2Zwo8/2N/MPrZdR/RJnBhbR0Zc/yNpCreRTyT05qlKcDLUdG/vf+nrfqY6hHRecYBvemfwo2q8OZjYQnmtzwfySbwWpDZlY6NTCbWfv2FpD/yrUY6Jz12yJV+W2zVzmXbm87rYmoyEiwJqztPQn8XmInIII1bBVGsJt32q7TzWN/LnUl43QzSctzgoPkCKapc7U3Tax5pTaqALH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+dPNGe8lZ8/T/3MHHnugG1RG1PEOTva8WBaypPfBtXIIXbMhvusAICW15zyjsvs9+nZUmGPicFyPtcP0FBDqfrmyzk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0519f3e-982a-4068-dc21-08d9df347886 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2365.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2022 12:24:30.4283 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: o6HnpPLq55Trq+l0b/c/pQ+VzsQHpMgrSbOM4CjeSkaKHszJGnf+YSRbrloytMS8J5uJ6nv8bMkk3QDtr3J1xnP9Wf5q7PaYetOiwXuVPzE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1734 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10236 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201240082 X-Proofpoint-ORIG-GUID: C3N97HIr4t49F0e4DbNpJnwUYb62Ut4J X-Proofpoint-GUID: C3N97HIr4t49F0e4DbNpJnwUYb62Ut4J Subject: [Intel-gfx] [PATCH] drm/i915/overlay: Prevent divide by zero bugs in scaling X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , kernel-janitors@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Chris Wilson , Eric Anholt , Sean Paul , Fernando Ramos Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Smatch detected a divide by zero bug in check_overlay_scaling(). drivers/gpu/drm/i915/display/intel_overlay.c:976 check_overlay_scaling() error: potential divide by zero bug '/ rec->dst_height'. drivers/gpu/drm/i915/display/intel_overlay.c:980 check_overlay_scaling() error: potential divide by zero bug '/ rec->dst_width'. Prevent this by ensuring that the dst height and width are non-zero. Fixes: 02e792fbaadb ("drm/i915: implement drmmode overlay support v4") Signed-off-by: Dan Carpenter --- From static analysis. Not tested. drivers/gpu/drm/i915/display/intel_overlay.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_overlay.c b/drivers/gpu/drm/i915/display/intel_overlay.c index 1a376e9a1ff3..d610e48cab94 100644 --- a/drivers/gpu/drm/i915/display/intel_overlay.c +++ b/drivers/gpu/drm/i915/display/intel_overlay.c @@ -959,6 +959,9 @@ static int check_overlay_dst(struct intel_overlay *overlay, const struct intel_crtc_state *pipe_config = overlay->crtc->config; + if (rec->dst_height == 0 || rec->dst_width == 0) + return -EINVAL; + if (rec->dst_x < pipe_config->pipe_src_w && rec->dst_x + rec->dst_width <= pipe_config->pipe_src_w && rec->dst_y < pipe_config->pipe_src_h &&